Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub(crate) enum Subcommand {
Gc(gc::Gc),
#[command(about = "Print file hash")]
Hash(hash::Hash),
#[command(about = "Print info")]
#[command(about = "Print configuration and state")]
Info,
#[command(about = "Print public key")]
Key(key::Key),
Expand All @@ -96,7 +96,7 @@ pub(crate) enum Subcommand {
Metadata(metadata::Metadata),
#[command(about = "Print reference")]
Reference,
#[command(about = "Start a Filepack server")]
#[command(about = "Start Filepack server")]
Serve(serve::Serve),
#[command(about = "Sign manifest")]
Sign(sign::Sign),
Expand Down
7 changes: 5 additions & 2 deletions src/subcommand/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ use super::*;
#[derive(Json, Serialize)]
pub(crate) struct Info {
/// Path to the data directory.
data: Utf8PathBuf,
data_dir: Utf8PathBuf,
/// Path to the keychain directory.
keychain: Utf8PathBuf,
/// Public keys in the keychain, by name.
keys: BTreeMap<KeyName, PublicKey>,
/// Filepack version.
version: String,
}

pub(crate) type Input = ();
Expand All @@ -19,9 +21,10 @@ pub(crate) fn run(options: Options) -> Result {
let keychain = Keychain::load(&options)?;

let info = Output {
data: options.data_dir()?,
data_dir: options.data_dir()?,
keychain: keychain.path,
keys: keychain.keys,
version: env!("CARGO_PKG_VERSION").into(),
};

println!("{}", serde_json::to_string_pretty(&info).unwrap());
Expand Down
2 changes: 1 addition & 1 deletion tests/completions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ fn subcommands() {
Test::new()
.env("FILEPACK_COMPLETE", "fish")
.args(["--", "filepack", "ser"])
.stdout("serve\tStart a Filepack server\n")
.stdout("serve\tStart Filepack server\n")
.success();
}
12 changes: 8 additions & 4 deletions tests/data_dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ fn default() {
.env("HOME", "foo")
.arg("info")
.stdout(json_pretty! {
data: "foo/.filepack",
data_dir: "foo/.filepack",
keychain: "foo/.filepack/keychain",
keys: {},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
Expand All @@ -21,9 +22,10 @@ fn flag() {
Test::new()
.args(["--data-dir", "foo", "info"])
.stdout_regex_path(&json_regex! {
data: "foo",
data_dir: "foo",
keychain: "foo/keychain",
keys: {},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
Expand All @@ -35,9 +37,10 @@ fn xdg_data_home() {
.env("XDG_DATA_HOME", "foo")
.arg("info")
.stdout_regex_path(&json_regex! {
data: "foo/filepack",
data_dir: "foo/filepack",
keychain: "foo/filepack/keychain",
keys: {},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
Expand All @@ -51,9 +54,10 @@ fn xdg_data_home_empty() {
.env("XDG_DATA_HOME", "")
.arg("info")
.stdout(json_pretty! {
data: "foo/.filepack",
data_dir: "foo/.filepack",
keychain: "foo/.filepack/keychain",
keys: {},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
9 changes: 6 additions & 3 deletions tests/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ fn no_keychain() {
Test::new()
.arg("info")
.stdout_regex(&json_regex! {
data: ".*",
data_dir: ".*",
keychain: ".*keychain",
keys: {
},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
Expand All @@ -20,10 +21,11 @@ fn no_keys() {
.chmod("keychain", 0o700)
.arg("info")
.stdout_regex(&json_regex! {
data: ".*",
data_dir: ".*",
keychain: ".*keychain",
keys: {
},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
Expand All @@ -42,12 +44,13 @@ fn with_keys() {
test
.arg("info")
.stdout_regex(&json_regex! {
data: ".*",
data_dir: ".*",
keychain: ".*keychain",
keys: {
master: master,
foo: foo,
},
version: (env!("CARGO_PKG_VERSION")),
})
.success();
}
Loading