cli

Command-line interface for Radroots
git clone https://radroots.dev/git/cli.git
Log | Files | Refs | README | LICENSE

global.rs (7273B)


      1 use std::path::PathBuf;
      2 
      3 use crate::runtime::config::OutputFormat;
      4 
      5 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
      6 pub enum RuntimeOutputFormatArg {
      7     Human,
      8     Json,
      9     Ndjson,
     10 }
     11 
     12 impl RuntimeOutputFormatArg {
     13     pub fn as_output_format(self) -> OutputFormat {
     14         match self {
     15             Self::Human => OutputFormat::Human,
     16             Self::Json => OutputFormat::Json,
     17             Self::Ndjson => OutputFormat::Ndjson,
     18         }
     19     }
     20 }
     21 
     22 #[derive(Debug, Clone, Default)]
     23 pub struct RuntimeInvocationArgs {
     24     pub output_format: Option<RuntimeOutputFormatArg>,
     25     pub json: bool,
     26     pub ndjson: bool,
     27     pub env_file: Option<PathBuf>,
     28     pub quiet: bool,
     29     pub verbose: bool,
     30     pub trace: bool,
     31     pub dry_run: bool,
     32     pub no_color: bool,
     33     pub no_input: bool,
     34     pub yes: bool,
     35     pub log_filter: Option<String>,
     36     pub log_dir: Option<PathBuf>,
     37     pub log_stdout: bool,
     38     pub no_log_stdout: bool,
     39     pub account: Option<String>,
     40     pub identity_path: Option<PathBuf>,
     41     pub signer: Option<String>,
     42     pub publish_transport: Option<String>,
     43     pub relay: Vec<String>,
     44     pub myc_executable: Option<PathBuf>,
     45     pub myc_status_timeout_ms: Option<u64>,
     46     pub hyf_enabled: bool,
     47     pub no_hyf_enabled: bool,
     48     pub hyf_executable: Option<PathBuf>,
     49 }
     50 
     51 #[derive(Debug, Clone, Copy)]
     52 pub enum LocalExportFormatArg {
     53     Json,
     54     Ndjson,
     55 }
     56 
     57 impl LocalExportFormatArg {
     58     pub fn as_str(self) -> &'static str {
     59         match self {
     60             Self::Json => "json",
     61             Self::Ndjson => "ndjson",
     62         }
     63     }
     64 }
     65 
     66 #[derive(Debug, Clone)]
     67 pub struct SyncWatchArgs {
     68     pub frames: usize,
     69     pub interval_ms: u64,
     70 }
     71 
     72 #[derive(Debug, Clone)]
     73 pub struct FindQueryArgs {
     74     pub query: Vec<String>,
     75 }
     76 
     77 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
     78 pub enum FarmScopeArg {
     79     User,
     80     Workspace,
     81 }
     82 
     83 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
     84 pub enum FarmFieldArg {
     85     Name,
     86     DisplayName,
     87     About,
     88     Website,
     89     Picture,
     90     Banner,
     91     Location,
     92     City,
     93     Region,
     94     Country,
     95     Delivery,
     96 }
     97 
     98 #[derive(Debug, Clone, Default)]
     99 pub struct FarmScopedArgs {
    100     pub scope: Option<FarmScopeArg>,
    101 }
    102 
    103 #[derive(Debug, Clone, Default)]
    104 pub struct FarmCreateArgs {
    105     pub scope: Option<FarmScopeArg>,
    106     pub farm_d_tag: Option<String>,
    107     pub name: Option<String>,
    108     pub display_name: Option<String>,
    109     pub about: Option<String>,
    110     pub website: Option<String>,
    111     pub picture: Option<String>,
    112     pub banner: Option<String>,
    113     pub location: Option<String>,
    114     pub city: Option<String>,
    115     pub region: Option<String>,
    116     pub country: Option<String>,
    117     pub delivery_method: Option<String>,
    118 }
    119 
    120 #[derive(Debug, Clone)]
    121 pub struct FarmRebindArgs {
    122     pub scope: Option<FarmScopeArg>,
    123     pub selector: String,
    124 }
    125 
    126 #[derive(Debug, Clone)]
    127 pub struct FarmUpdateArgs {
    128     pub scope: Option<FarmScopeArg>,
    129     pub field: FarmFieldArg,
    130     pub value: Vec<String>,
    131 }
    132 
    133 #[derive(Debug, Clone, Default)]
    134 pub struct FarmPublishArgs {
    135     pub scope: Option<FarmScopeArg>,
    136     pub idempotency_key: Option<String>,
    137     pub print_event: bool,
    138 }
    139 
    140 #[derive(Debug, Clone, Default)]
    141 pub struct ListingCreateArgs {
    142     pub output: Option<PathBuf>,
    143     pub key: Option<String>,
    144     pub title: Option<String>,
    145     pub category: Option<String>,
    146     pub summary: Option<String>,
    147     pub bin_id: Option<String>,
    148     pub quantity_amount: Option<String>,
    149     pub quantity_unit: Option<String>,
    150     pub price_amount: Option<String>,
    151     pub price_currency: Option<String>,
    152     pub price_per_amount: Option<String>,
    153     pub price_per_unit: Option<String>,
    154     pub available: Option<String>,
    155     pub label: Option<String>,
    156     pub discount_id: Option<String>,
    157     pub discount_label: Option<String>,
    158     pub discount_kind: Option<String>,
    159     pub discount_value: Option<String>,
    160     pub discount_amount: Option<String>,
    161     pub discount_currency: Option<String>,
    162 }
    163 
    164 #[derive(Debug, Clone)]
    165 pub struct ListingFileArgs {
    166     pub file: PathBuf,
    167 }
    168 
    169 #[derive(Debug, Clone)]
    170 pub struct ListingAppRecordExportArgs {
    171     pub record_id: String,
    172     pub output: Option<PathBuf>,
    173 }
    174 
    175 #[derive(Debug, Clone)]
    176 pub struct ListingRebindArgs {
    177     pub file: PathBuf,
    178     pub selector: String,
    179     pub farm_d_tag: Option<String>,
    180 }
    181 
    182 #[derive(Debug, Clone)]
    183 pub struct ListingMutationArgs {
    184     pub file: PathBuf,
    185     pub idempotency_key: Option<String>,
    186     pub print_event: bool,
    187     pub offline: bool,
    188 }
    189 
    190 #[derive(Debug, Clone, Default)]
    191 pub struct OrderDraftCreateArgs {
    192     pub listing: Option<String>,
    193     pub listing_addr: Option<String>,
    194     pub bin_id: Option<String>,
    195     pub bin_count: Option<u32>,
    196     pub adjustments: Vec<OrderDraftAdjustmentArgs>,
    197 }
    198 
    199 #[derive(Debug, Clone, Default)]
    200 pub struct OrderDraftAdjustmentArgs {
    201     pub id: String,
    202     pub effect: String,
    203     pub amount: String,
    204     pub currency: String,
    205     pub reason: String,
    206 }
    207 
    208 #[derive(Debug, Clone)]
    209 pub struct OrderSubmitArgs {
    210     pub key: String,
    211     pub idempotency_key: Option<String>,
    212 }
    213 
    214 #[derive(Debug, Clone)]
    215 pub struct OrderAppRecordExportArgs {
    216     pub record_id: String,
    217     pub output: Option<PathBuf>,
    218 }
    219 
    220 #[derive(Debug, Clone)]
    221 pub struct OrderRebindArgs {
    222     pub key: String,
    223     pub selector: String,
    224 }
    225 
    226 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
    227 pub enum OrderDecisionArg {
    228     Accept,
    229     Decline,
    230 }
    231 
    232 impl OrderDecisionArg {
    233     pub fn as_str(self) -> &'static str {
    234         match self {
    235             Self::Accept => "accepted",
    236             Self::Decline => "declined",
    237         }
    238     }
    239 
    240     pub fn command(self) -> &'static str {
    241         match self {
    242             Self::Accept => "accept",
    243             Self::Decline => "decline",
    244         }
    245     }
    246 }
    247 
    248 #[derive(Debug, Clone)]
    249 pub struct OrderDecisionArgs {
    250     pub key: String,
    251     pub decision: OrderDecisionArg,
    252     pub reason: Option<String>,
    253     pub idempotency_key: Option<String>,
    254 }
    255 
    256 #[derive(Debug, Clone)]
    257 pub struct OrderCancelArgs {
    258     pub key: String,
    259     pub reason: String,
    260     pub idempotency_key: Option<String>,
    261 }
    262 
    263 #[derive(Debug, Clone)]
    264 pub struct OrderRevisionProposeArgs {
    265     pub key: String,
    266     pub reason: String,
    267     pub bin_id: Option<String>,
    268     pub bin_count: Option<u32>,
    269     pub adjustment_id: Option<String>,
    270     pub adjustment_effect: Option<String>,
    271     pub adjustment_amount: Option<String>,
    272     pub adjustment_currency: Option<String>,
    273     pub adjustment_reason: Option<String>,
    274     pub idempotency_key: Option<String>,
    275 }
    276 
    277 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
    278 pub enum OrderRevisionDecisionArg {
    279     Accept,
    280     Decline,
    281 }
    282 
    283 impl OrderRevisionDecisionArg {
    284     pub fn as_str(self) -> &'static str {
    285         match self {
    286             Self::Accept => "accepted",
    287             Self::Decline => "declined",
    288         }
    289     }
    290 
    291     pub fn command(self) -> &'static str {
    292         match self {
    293             Self::Accept => "accept",
    294             Self::Decline => "decline",
    295         }
    296     }
    297 }
    298 
    299 #[derive(Debug, Clone)]
    300 pub struct OrderRevisionDecisionArgs {
    301     pub key: String,
    302     pub revision_id: String,
    303     pub decision: OrderRevisionDecisionArg,
    304     pub reason: Option<String>,
    305     pub idempotency_key: Option<String>,
    306 }
    307 
    308 #[derive(Debug, Clone)]
    309 pub struct OrderStatusArgs {
    310     pub key: String,
    311 }
    312 
    313 #[derive(Debug, Clone)]
    314 pub struct RecordLookupArgs {
    315     pub key: String,
    316 }