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
24Use \"heddle init\" to start a repository or keep working in Git mode.
25Use \"heddle clone\" to download an existing hosted Heddle repository.
26")]
27pub struct ImportArgs {
28    #[command(subcommand)]
29    pub command: ImportCommands,
30}
31
32#[derive(Subcommand, Clone, Debug)]
33pub enum ImportCommands {
34    /// Import a Git checkout on this computer.
35    Local(ImportLocalArgs),
36
37    /// Have the server import a public HTTPS Git URL.
38    #[cfg(feature = "client")]
39    Url(ImportUrlArgs),
40
41    /// Watch a durable import operation until it reaches a terminal state.
42    ///
43    /// With `--output json`, emits JSONL: one `import_operation` document per
44    /// committed version, each carrying `operation_id` and `terminal`.
45    #[cfg(feature = "client")]
46    Status(ImportOperationArgs),
47
48    /// Retry a failed durable import operation.
49    #[cfg(feature = "client")]
50    Retry(ImportOperationArgs),
51}
52
53#[cfg(feature = "client")]
54#[derive(Args, Clone, Debug)]
55pub struct ImportUrlArgs {
56    /// Public HTTPS Git URL for the server to fetch.
57    #[arg(value_name = "URL")]
58    pub url: String,
59
60    /// Hosted destination spool path or URL.
61    #[arg(long, value_name = "SPOOL|URL")]
62    pub to: String,
63
64    /// Name of the imported native thread (default: main).
65    #[arg(long, value_name = "NAME")]
66    pub thread: Option<String>,
67
68    /// Heddle server address when --to is a spool path.
69    #[arg(long, value_name = "HOST")]
70    pub server: Option<String>,
71}
72
73#[cfg(feature = "client")]
74#[derive(Args, Clone, Debug)]
75pub struct ImportOperationArgs {
76    /// Durable operation-record ID returned by import URL or retry.
77    #[arg(value_name = "OPERATION")]
78    pub operation: String,
79
80    /// Hosted destination spool path or URL.
81    #[arg(long, value_name = "SPOOL|URL")]
82    pub to: String,
83
84    /// Heddle server address when --to is a spool path.
85    #[arg(long, value_name = "HOST")]
86    pub server: Option<String>,
87}