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
//! `tm env` — edit a dotenv file without printing a value (#8939).
//!
//! Why: owner ruling item 44 — the Architect manages a project's env files,
//! and the pm-guard lets only these two shapes through (Architect rulings
//! Q1-Q4).
//! What: [`EnvAction`] — `set` and `keys`.
//! Test: `cli_parses_env_set_and_keys`.
use std::path::PathBuf;
use clap::Subcommand;
/// Actions for the `env` subcommand.
#[derive(Debug, Subcommand)]
pub(crate) enum EnvAction {
/// Set one key in a dotenv file, never printing its value.
///
/// The value is read only from the login Keychain, with
/// `--from-keychain <service> --account <account>`; stdin is refused.
/// A `KEY=value` argument is refused. Writes atomically with mode 0600
/// and follows no symlink. Only the bound Architect's main thread may run
/// it, as its own direct call, on a dotenv file in its scope.
Set {
/// The dotenv file.
path: PathBuf,
/// The key name.
key: String,
/// Read the value from this login-Keychain service.
#[arg(long, value_name = "SERVICE", requires = "account")]
from_keychain: Option<String>,
/// The Keychain item's account.
#[arg(long, value_name = "ACCOUNT", requires = "from_keychain")]
account: Option<String>,
/// Refused: the value never goes on the command line.
#[arg(hide = true)]
extra: Vec<String>,
},
/// Print a dotenv file's key names, never a value.
///
/// Fails with no output when any line is not blank, a comment or a
/// `KEY=value` assignment. Refuses a symlink or a non-regular file. Only
/// the bound Architect's main thread may run it, as its own direct call,
/// on a dotenv file in its scope.
Keys {
/// The dotenv file.
path: PathBuf,
},
}