heddle-cli-args 0.30.0

Heddle's command-line argument surface.
Documentation
// SPDX-License-Identifier: Apache-2.0
//! Repository import command definitions.

use clap::{Args, Subcommand};

use super::ImportLocalArgs;

#[derive(Args, Clone, Debug)]
#[command(verbatim_doc_comment)]
#[command(about = "Bring an existing Git repository into Heddle.")]
#[command(long_about = "Bring an existing Git repository into Heddle.")]
#[command(after_help = "\
Choose a source:
  local  Import a Git checkout on this computer.
  url    Have the server import a public HTTPS Git URL.

Already checked out the repository?
  heddle import local .
  heddle push <destination>

Want the server to fetch it, without a local checkout?
  heddle import url https://github.com/acme/widget.git --to <handle>/widget

Manage a hosted import:
  heddle import status <operation> --to <handle>/widget
  heddle import cancel <operation> --to <handle>/widget

Use \"heddle init\" to start a repository or keep working in Git mode.
Use \"heddle clone\" to download an existing hosted Heddle repository.
")]
pub struct ImportArgs {
    #[command(subcommand)]
    pub command: ImportCommands,
}

#[derive(Subcommand, Clone, Debug)]
pub enum ImportCommands {
    /// Import a Git checkout on this computer.
    Local(ImportLocalArgs),

    /// Have the server import a public HTTPS Git URL, with one Thread per branch.
    #[cfg(feature = "client")]
    Url(ImportUrlArgs),

    /// Watch a durable import operation until it reaches a terminal state.
    ///
    /// With `--output json`, emits JSONL: one `import_operation` document per
    /// committed version, each carrying `operation_id` and `terminal`.
    #[cfg(feature = "client")]
    Status(ImportOperationArgs),

    /// Retry a failed durable import operation.
    #[cfg(feature = "client")]
    Retry(ImportOperationArgs),

    /// Request cancellation of a hosted import operation.
    ///
    /// Uses the same operation/job record ID as status and retry, and your
    /// normal hosted credentials. The server decides whether cancellation is
    /// supported and permitted. Acknowledgement is not terminal cancellation
    /// or rollback; use `heddle import status` to observe the outcome.
    /// Completed, failed, or canceled operations succeed without a cancel request.
    /// With `--output json`, emits `import_cancel` with status `requested` or
    /// `already_terminal` and the observed state. Errors use the stderr envelope.
    #[cfg(feature = "client")]
    #[command(after_help = "Exit codes:
  0   Cancellation requested or operation already terminal.
  64  Invalid arguments.
  74  IO failure.
  75  Transient failure; safe to retry.
  76  Server refused cancellation or rejected the request.
  77  Caller is not authorized.
  78  Missing configuration or operation (including another account's operation).")]
    Cancel(ImportOperationArgs),
}

#[cfg(feature = "client")]
#[derive(Args, Clone, Debug)]
pub struct ImportUrlArgs {
    /// Public HTTPS Git URL for the server to fetch.
    #[arg(value_name = "URL")]
    pub url: String,

    /// Hosted destination spool path or URL.
    #[arg(long, value_name = "SPOOL|URL")]
    pub to: String,

    /// Heddle server address when --to is a spool path.
    #[arg(long, value_name = "HOST")]
    pub server: Option<String>,
}

#[cfg(feature = "client")]
#[derive(Args, Clone, Debug)]
pub struct ImportOperationArgs {
    /// Operation/job record ID returned by import URL or retry (not a client --op-id).
    #[arg(value_name = "OPERATION")]
    pub operation: String,

    /// Hosted destination spool path or URL.
    #[arg(long, value_name = "SPOOL|URL")]
    pub to: String,

    /// Heddle server address when --to is a spool path.
    #[arg(long, value_name = "HOST")]
    pub server: Option<String>,
}