in src/rust/engine/fs/fs_util/src/main.rs [76:253]
fn main() {
env_logger::init();
match execute(
&App::new("fs_util")
.subcommand(
SubCommand::with_name("file")
.subcommand(
SubCommand::with_name("cat")
.about("Output the contents of a file by fingerprint.")
.arg(Arg::with_name("fingerprint").required(true).takes_value(
true,
))
.arg(Arg::with_name("size_bytes").required(true).takes_value(
true,
)),
)
.subcommand(
SubCommand::with_name("save")
.about(
"Ingest a file by path, which allows it to be used in Directories/Snapshots. \
Outputs a fingerprint of its contents and its size in bytes, separated by a space.",
)
.arg(Arg::with_name("path").required(true).takes_value(true))
.arg(Arg::with_name("output-mode").long("output-mode").possible_values(&["json", "simple"]).default_value("simple").multiple(false).takes_value(true).help(
"Set to manipulate the way a report is displayed."
)),
),
)
.subcommand(
SubCommand::with_name("directory")
.subcommand(
SubCommand::with_name("materialize")
.about(
"Materialize a directory by fingerprint to the filesystem. \
Destination must not exist before this command is run.",
)
.arg(Arg::with_name("fingerprint").required(true).takes_value(
true,
))
.arg(Arg::with_name("size_bytes").required(true).takes_value(
true,
))
.arg(Arg::with_name("destination").required(true).takes_value(
true,
)),
)
.subcommand(
SubCommand::with_name("save")
.about(
"Ingest a directory recursively. Saves all files found therein and saves Directory \
protos for each directory found. Outputs a fingerprint of the canonical top-level Directory proto \
and the size of the serialized proto in bytes, separated by a space.",
)
.arg(
Arg::with_name("globs")
.required(true)
.takes_value(true)
.multiple(true)
.help(
"globs matching the files and directories which should be included in the \
directory, relative to the root.",
),
)
.arg(Arg::with_name("root").long("root").required(true).takes_value(true).help(
"Root under which the globs live. The Directory proto produced will be relative \
to this directory.",
))
.arg(Arg::with_name("output-mode").long("output-mode").possible_values(&["json", "simple"]).default_value("simple").multiple(false).takes_value(true).help(
"Set to manipulate the way a report is displayed."
)),
)
.subcommand(
SubCommand::with_name("cat-proto")
.about(
"Output the bytes of a serialized Directory proto addressed by fingerprint.",
)
.arg(
Arg::with_name("output-format")
.long("output-format")
.takes_value(true)
.default_value("binary")
.possible_values(&["binary", "recursive-file-list", "recursive-file-list-with-digests", "text"]),
)
.arg(Arg::with_name("fingerprint").required(true).takes_value(
true,
))
.arg(Arg::with_name("size_bytes").required(true).takes_value(
true,
)),
),
)
.subcommand(
SubCommand::with_name("cat")
.about(
"Output the contents of a file or Directory proto addressed by fingerprint.",
)
.arg(Arg::with_name("fingerprint").required(true).takes_value(
true,
))
.arg(Arg::with_name("size_bytes").required(true).takes_value(
true,
)),
)
.subcommand(
SubCommand::with_name("gc")
.about("Garbage collect the on-disk store. Note that after running this command, any processes with an open store (e.g. a pantsd) may need to re-initialize their store.")
.arg(
Arg::with_name("target-size-bytes")
.takes_value(true)
.long("target-size-bytes")
.required(true),
)
)
.arg(
Arg::with_name("local-store-path")
.takes_value(true)
.long("local-store-path")
.required(false),
)
.arg(
Arg::with_name("server-address")
.takes_value(true)
.long("server-address")
.required(false)
.multiple(true)
.number_of_values(1)
)
.arg(
Arg::with_name("root-ca-cert-file")
.help("Path to file containing root certificate authority certificates. If not set, TLS will not be used when connecting to the remote.")
.takes_value(true)
.long("root-ca-cert-file")
.required(false)
)
.arg(
Arg::with_name("oauth-bearer-token-file")
.help("Path to file containing oauth bearer token. If not set, no authorization will be provided to remote servers.")
.takes_value(true)
.long("oauth-bearer-token-file")
.required(false)
)
.arg(Arg::with_name("remote-instance-name")
.takes_value(true)
.long("remote-instance-name")
.required(false))
.arg(
Arg::with_name("chunk-bytes")
.help("Number of bytes to include per-chunk when uploading bytes. grpc imposes a hard message-size limit of around 4MB.")
.takes_value(true)
.long("chunk-bytes")
.required(false)
.default_value(&format!("{}", 3 * 1024 * 1024))
).arg(
Arg::with_name("thread-count")
.help("Number of threads to use for uploads and downloads")
.takes_value(true)
.long("thread-count")
.required(false)
.default_value("1")
)
.arg(
Arg::with_name("rpc-attempts")
.help("Number of times to attempt any RPC before giving up.")
.takes_value(true)
.long("rpc-attempts")
.required(false)
.default_value("3")
)
.get_matches(),
) {
Ok(_) => {}
Err(err) => {
eprintln!("{}", err.0);
exit(err.1 as i32)
}
};
}