Skip to content

Commit 1abd587

Browse files
committed
feat(hm-cloud): scaffold crate with the cloud CLI tree
New crate that will own the whole cloud domain (executor + verbs). This first step lands the clap command tree only, no runtime: - CloudCommand { Auth{login,logout,whoami}, Org, Pipeline, Build, Job, Billing } with every arg documented. - Pipeline-identifying args are Option<String> so an omitted --pipeline falls back to config.default_pipeline. - No submit verb: submission stays with hm run --cloud.
1 parent 85e007b commit 1abd587

5 files changed

Lines changed: 193 additions & 0 deletions

File tree

‎Cargo.lock‎

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
resolver = "2"
33
members = [
44
"crates/hm",
5+
"crates/hm-cloud",
56
"crates/hm-common",
67
"crates/hm-core",
78
"crates/hm-plugin-protocol",
@@ -12,6 +13,7 @@ members = [
1213
]
1314
default-members = [
1415
"crates/hm",
16+
"crates/hm-cloud",
1517
"crates/hm-common",
1618
"crates/hm-core",
1719
"crates/hm-plugin-protocol",
@@ -28,6 +30,7 @@ repository = "https://github.com/harmont-dev/harmont-cli"
2830

2931
[workspace.dependencies]
3032
hm-core = { path = "crates/hm-core", version = "0.0.0-dev" }
33+
hm-cloud = { path = "crates/hm-cloud", version = "0.0.0-dev" }
3134
hm-plugin-protocol = { path = "crates/hm-plugin-protocol", version = "0.0.0-dev" }
3235
hm-pipeline-ir = { path = "crates/hm-pipeline-ir", version = "0.0.0-dev" }
3336
hm-dsl-engine = { path = "crates/hm-dsl-engine", version = "0.0.0-dev" }

‎crates/hm-cloud/Cargo.toml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "hm-cloud"
3+
version = "0.0.0-dev"
4+
edition.workspace = true
5+
license.workspace = true
6+
repository.workspace = true
7+
description = "Harmont cloud execution backend and `hm cloud` command surface."
8+
keywords = ["ci", "harmont", "cloud"]
9+
categories = ["command-line-utilities"]
10+
11+
[lib]
12+
path = "src/lib.rs"
13+
14+
[dependencies]
15+
clap = { version = "4", features = ["derive"] }
16+
17+
[lints]
18+
workspace = true

‎crates/hm-cloud/src/cli.rs‎

Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
//! The `hm cloud` command tree.
2+
3+
use clap::Subcommand;
4+
5+
#[derive(Debug, Clone, Subcommand)]
6+
pub enum CloudCommand {
7+
/// Authenticate and inspect the active session.
8+
#[command(subcommand)]
9+
Auth(AuthCommand),
10+
/// Manage organizations.
11+
#[command(subcommand)]
12+
Org(OrgCommand),
13+
/// Manage pipelines.
14+
#[command(subcommand)]
15+
Pipeline(PipelineCommand),
16+
/// Manage builds.
17+
#[command(subcommand)]
18+
Build(BuildCommand),
19+
/// Manage jobs.
20+
#[command(subcommand)]
21+
Job(JobCommand),
22+
/// Manage credits, top-ups, and usage.
23+
#[command(subcommand)]
24+
Billing(BillingCommand),
25+
}
26+
27+
#[derive(Debug, Clone, Subcommand)]
28+
pub enum AuthCommand {
29+
/// Authenticate this CLI against the Harmont API.
30+
Login {
31+
/// Skip the loopback flow and prompt for a paste-in code.
32+
#[arg(long)]
33+
paste: bool,
34+
},
35+
/// Remove stored credentials.
36+
Logout,
37+
/// Show the authenticated user.
38+
Whoami,
39+
}
40+
41+
#[derive(Debug, Clone, Subcommand)]
42+
pub enum OrgCommand {
43+
/// Set the active organization.
44+
Switch {
45+
/// Organization slug.
46+
slug: String,
47+
},
48+
}
49+
50+
#[derive(Debug, Clone, Subcommand)]
51+
pub enum PipelineCommand {
52+
/// List pipelines for the active organization.
53+
List,
54+
/// Show pipeline details by slug. Defaults to the configured pipeline.
55+
Show {
56+
/// Pipeline slug; defaults to the configured pipeline.
57+
slug: Option<String>,
58+
},
59+
}
60+
61+
#[derive(Debug, Clone, Subcommand)]
62+
pub enum BuildCommand {
63+
/// List builds for a pipeline.
64+
List {
65+
/// Pipeline slug; defaults to the configured pipeline.
66+
#[arg(short, long)]
67+
pipeline: Option<String>,
68+
},
69+
/// Show a build by number.
70+
Show {
71+
/// Pipeline slug; defaults to the configured pipeline.
72+
#[arg(short, long)]
73+
pipeline: Option<String>,
74+
/// Build number.
75+
number: i64,
76+
},
77+
/// Cancel a build.
78+
Cancel {
79+
/// Pipeline slug; defaults to the configured pipeline.
80+
#[arg(short, long)]
81+
pipeline: Option<String>,
82+
/// Build number.
83+
number: i64,
84+
},
85+
/// Watch a build until it reaches a terminal state.
86+
Watch {
87+
/// Pipeline slug; defaults to the configured pipeline.
88+
#[arg(short, long)]
89+
pipeline: Option<String>,
90+
/// Build number.
91+
number: i64,
92+
},
93+
}
94+
95+
#[derive(Debug, Clone, Subcommand)]
96+
pub enum JobCommand {
97+
/// List jobs in a build.
98+
List {
99+
/// Pipeline slug; defaults to the configured pipeline.
100+
#[arg(short, long)]
101+
pipeline: Option<String>,
102+
/// Build number.
103+
#[arg(short, long)]
104+
build: i64,
105+
},
106+
/// Show a job by id.
107+
Show {
108+
/// Pipeline slug; defaults to the configured pipeline.
109+
#[arg(short, long)]
110+
pipeline: Option<String>,
111+
/// Build number.
112+
#[arg(short, long)]
113+
build: i64,
114+
/// Job id.
115+
job_id: String,
116+
},
117+
/// Print the job log.
118+
Log {
119+
/// Pipeline slug; defaults to the configured pipeline.
120+
#[arg(short, long)]
121+
pipeline: Option<String>,
122+
/// Build number.
123+
#[arg(short, long)]
124+
build: i64,
125+
/// Job id.
126+
job_id: String,
127+
},
128+
}
129+
130+
#[derive(Debug, Clone, Subcommand)]
131+
pub enum BillingCommand {
132+
/// Print the current credit balance.
133+
Balance,
134+
/// List billing transactions.
135+
Transactions {
136+
/// Maximum number of transactions to return.
137+
#[arg(long, default_value = "100")]
138+
limit: u32,
139+
},
140+
/// Show usage over a time window.
141+
Usage {
142+
/// Start of the usage window.
143+
#[arg(long)]
144+
from: Option<String>,
145+
/// End of the usage window.
146+
#[arg(long)]
147+
to: Option<String>,
148+
},
149+
/// Top up credits via Stripe checkout.
150+
Topup {
151+
/// Amount to add, in whole US dollars.
152+
amount_usd: u32,
153+
/// Print the checkout URL instead of opening a browser.
154+
#[arg(long)]
155+
no_browser: bool,
156+
},
157+
/// Redeem a coupon code.
158+
Redeem {
159+
/// Coupon code.
160+
code: String,
161+
},
162+
}

‎crates/hm-cloud/src/lib.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//! Harmont cloud: the cloud execution backend and `hm cloud` command surface.
2+
3+
pub mod cli;

0 commit comments

Comments
 (0)