Skip to main content

heddle_cli_args/cli/cli_args/
commands_import.rs

1// SPDX-License-Identifier: Apache-2.0
2//! Repository import command definitions.
3
4use clap::{Args, Subcommand};
5
6use super::ImportLocalArgs;
7
8#[derive(Args, Clone, Debug)]
9#[command(verbatim_doc_comment)]
10#[command(about = "Bring an existing Git repository into Heddle.")]
11#[command(long_about = "Bring an existing Git repository into Heddle.")]
12#[command(after_help = "\
13Choose a source:
14  local  Import a Git checkout on this computer.
15  url    Have the server import a public HTTPS Git URL.
16
17Already checked out the repository?
18  heddle import local .
19  heddle push <destination>
20
21Want the server to fetch it, without a local checkout?
22  heddle import url https://github.com/acme/widget.git --to <handle>/widget
23
24Manage a hosted import:
25  heddle import status <operation> --to <handle>/widget
26  heddle import cancel <operation> --to <handle>/widget
27
28Use \"heddle init\" to start a repository or keep working in Git mode.
29Use \"heddle clone\" to download an existing hosted Heddle repository.
30")]
31pub struct ImportArgs {
32    #[command(subcommand)]
33    pub command: ImportCommands,
34}
35
36#[derive(Subcommand, Clone, Debug)]
37pub enum ImportCommands {
38    /// Import a Git checkout on this computer.
39    Local(ImportLocalArgs),
40
41    /// Have the server import a public HTTPS Git URL, with one Thread per branch.
42    #[cfg(feature = "client")]
43    Url(ImportUrlArgs),
44
45    /// Watch a durable import operation until it reaches a terminal state.
46    ///
47    /// With `--output json`, emits JSONL: one `import_operation` document per
48    /// committed version, each carrying `operation_id` and `terminal`.
49    #[cfg(feature = "client")]
50    Status(ImportOperationArgs),
51
52    /// Retry a failed durable import operation.
53    #[cfg(feature = "client")]
54    Retry(ImportOperationArgs),
55
56    /// Request cancellation of a hosted import operation.
57    ///
58    /// Uses the same operation/job record ID as status and retry, and your
59    /// normal hosted credentials. The server decides whether cancellation is
60    /// supported and permitted. Acknowledgement is not terminal cancellation
61    /// or rollback; use `heddle import status` to observe the outcome.
62    /// Completed, failed, or canceled operations succeed without a cancel request.
63    /// With `--output json`, emits `import_cancel` with status `requested` or
64    /// `already_terminal` and the observed state. Errors use the stderr envelope.
65    #[cfg(feature = "client")]
66    #[command(after_help = "Exit codes:
67  0   Cancellation requested or operation already terminal.
68  64  Invalid arguments.
69  74  IO failure.
70  75  Transient failure; safe to retry.
71  76  Server refused cancellation or rejected the request.
72  77  Caller is not authorized.
73  78  Missing configuration or operation (including another account's operation).")]
74    Cancel(ImportOperationArgs),
75}
76
77#[cfg(feature = "client")]
78#[derive(Args, Clone, Debug)]
79pub struct ImportUrlArgs {
80    /// Public HTTPS Git URL for the server to fetch.
81    #[arg(value_name = "URL")]
82    pub url: String,
83
84    /// Hosted destination spool path or URL.
85    #[arg(long, value_name = "SPOOL|URL")]
86    pub to: String,
87
88    /// Heddle server address when --to is a spool path.
89    #[arg(long, value_name = "HOST")]
90    pub server: Option<String>,
91}
92
93#[cfg(feature = "client")]
94#[derive(Args, Clone, Debug)]
95pub struct ImportOperationArgs {
96    /// Operation/job record ID returned by import URL or retry (not a client --op-id).
97    #[arg(value_name = "OPERATION")]
98    pub operation: String,
99
100    /// Hosted destination spool path or URL.
101    #[arg(long, value_name = "SPOOL|URL")]
102    pub to: String,
103
104    /// Heddle server address when --to is a spool path.
105    #[arg(long, value_name = "HOST")]
106    pub server: Option<String>,
107}