1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
use std::path::PathBuf;
use clap::{ArgAction, Args, Subcommand};
#[derive(Debug, Args)]
pub(crate) struct InstallArgs {
/// Fail if harn.lock would need to change.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub frozen: bool,
/// Alias for --frozen, intended for CI and production installs.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub locked: bool,
/// Do not fetch from package sources; use only harn.lock and the local cache.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue, conflicts_with = "refetch")]
pub offline: bool,
/// Force refetching one dependency (or every dependency with `--refetch all`).
#[arg(long, value_name = "ALIAS|all")]
pub refetch: Option<String>,
}
#[derive(Debug, Args)]
pub(crate) struct AddArgs {
/// Git URL/ref spec, local package path, or dependency name in the legacy `--git/--path` form.
pub name_or_spec: String,
/// Override the dependency alias written under `[dependencies]`.
#[arg(long)]
pub alias: Option<String>,
/// Git URL for a remote dependency.
#[arg(long, conflicts_with = "path")]
pub git: Option<String>,
/// Deprecated alias for `--rev` on the legacy `--git` form.
#[arg(long, conflicts_with_all = ["rev", "branch"])]
pub tag: Option<String>,
/// Git rev to pin for a remote dependency.
#[arg(long, conflicts_with = "branch")]
pub rev: Option<String>,
/// Git branch to track in the manifest; the lockfile still pins a commit.
#[arg(long, conflicts_with_all = ["rev", "tag"])]
pub branch: Option<String>,
/// Local path for a path dependency.
#[arg(long, conflicts_with = "git")]
pub path: Option<String>,
/// Package registry index URL or path for registry-name dependencies.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
}
#[derive(Debug, Args)]
pub(crate) struct UpdateArgs {
/// Refresh every dependency instead of one alias.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub all: bool,
/// Refresh only this dependency alias.
pub alias: Option<String>,
}
#[derive(Debug, Args)]
pub(crate) struct RemoveArgs {
/// Dependency alias to remove from harn.toml and harn.lock.
pub alias: String,
}
#[derive(Debug, Args)]
pub(crate) struct PackageArgs {
#[command(subcommand)]
pub command: PackageCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PackageCommand {
/// Search the package registry index.
Search(PackageSearchArgs),
/// Show package registry metadata for one package.
Info(PackageInfoArgs),
/// Validate a package manifest and publish readiness.
Check(PackageCheckArgs),
/// Build an inspectable package artifact directory.
Pack(PackagePackArgs),
/// Generate package API docs from exported Harn symbols.
Docs(PackageDocsArgs),
/// Inspect, clean, and verify the shared package cache.
Cache(PackageCacheArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PackageCheckArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Emit JSON instead of a human-readable report.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackagePackArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Output artifact directory. Defaults to .harn/dist/<name>-<version>.
#[arg(long, value_name = "DIR")]
pub output: Option<PathBuf>,
/// Validate and print the file list without writing the artifact.
#[arg(long)]
pub dry_run: bool,
/// Emit JSON instead of a human-readable report.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageDocsArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Output Markdown file. Defaults to docs/api.md.
#[arg(long, value_name = "PATH")]
pub output: Option<PathBuf>,
/// Verify the output file already matches generated docs.
#[arg(long)]
pub check: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageSearchArgs {
/// Search query. Omit to list all registry packages.
pub query: Option<String>,
/// Package registry index URL or path.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of a tab-separated table.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageInfoArgs {
/// Registry package name, optionally with @version.
pub name: String,
/// Package registry index URL or path.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of human-readable metadata.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PublishArgs {
/// Package directory, harn.toml, or file under the package. Defaults to cwd.
pub package: Option<PathBuf>,
/// Required until registry submission support lands.
#[arg(long)]
pub dry_run: bool,
/// Package registry index URL or path to report as the submission target.
#[arg(long, value_name = "URL|PATH")]
pub registry: Option<String>,
/// Emit JSON instead of a human-readable report.
#[arg(long)]
pub json: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageCacheArgs {
#[command(subcommand)]
pub command: PackageCacheCommand,
}
#[derive(Debug, Subcommand)]
pub(crate) enum PackageCacheCommand {
/// List cached git package entries.
List,
/// Remove cached git package entries not referenced by harn.lock, or every entry with --all.
Clean(PackageCacheCleanArgs),
/// Verify cached package contents against harn.lock.
Verify(PackageCacheVerifyArgs),
}
#[derive(Debug, Args)]
pub(crate) struct PackageCacheCleanArgs {
/// Remove every package cache entry instead of only entries unused by the current harn.lock.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub all: bool,
}
#[derive(Debug, Args)]
pub(crate) struct PackageCacheVerifyArgs {
/// Also verify materialized packages under .harn/packages/.
#[arg(long, default_value_t = false, action = ArgAction::SetTrue)]
pub materialized: bool,
}