{"record":{"id":"710733cce1c8fb1b","repo":"nikivdev/code","slug":"usage-f-hash-paths-or-unhash-args","errorCode":null,"errorMessage":"Usage: f hash <paths or unhash args>","messagePattern":"Usage: f hash <paths or unhash args>","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hash.rs","lineNumber":14,"sourceCode":"use std::env;\nuse std::io::IsTerminal;\nuse std::process::Command;\n\nuse anyhow::{Context, Result, bail};\n\nuse crate::cli::HashOpts;\nuse crate::env as flow_env;\n\nconst LINK_PREFIX: &str = \"unstash./\";\n\npub fn run(opts: HashOpts) -> Result<()> {\n    if opts.args.is_empty() {\n        bail!(\"Usage: f hash <paths or unhash args>\");\n    }\n\n    let unhash_bin = which::which(\"unhash\")\n        .context(\"unhash not found on PATH. Run `f deploy-unhash` in the unhash repo.\")?;\n\n    let mut cmd = Command::new(unhash_bin);\n    cmd.args(&opts.args);\n\n    if env::var(\"UNHASH_KEY\").is_err() {\n        if let Ok(Some(value)) = flow_env::get_personal_env_var(\"UNHASH_KEY\") {\n            cmd.env(\"UNHASH_KEY\", value);\n        }\n    }\n\n    let output = cmd.output().context(\"failed to run unhash\")?;\n    if !output.status.success() {\n        let stdout = String::from_utf8_lossy(&output.stdout);\n        let stderr = String::from_utf8_lossy(&output.stderr);","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/nikivdev/code/blob/a747e741ae92c09071d0ae946ab48488adcff1ce/src/hash.rs#L1-L32","documentation":"The `f hash` command wraps the external `unhash` binary. Its `run` entrypoint requires at least one argument (paths to hash or `unstash./`-prefixed unhash arguments). When `opts.args` is empty it bails immediately with this usage message before doing any work.","triggerScenarios":"Invoking `f hash` with no arguments at all from the shell or a script.","commonSituations":"Typing the command without arguments to 'test' it; a wrapper script that forwards `$@` when the user supplied nothing; a pipeline where a glob failed to expand and produced zero arguments.","solutions":["Pass one or more file paths to hash: `f hash src/main.rs src/lib.rs`","Pass unhash-style arguments prefixed with `unstash./` if you intend to unhash instead","Check your wrapper script actually forwards arguments (`f hash \"$@\"`, not `f hash`)"],"exampleFix":"# before\nf hash\n# after\nf hash src/main.rs README.md","handlingStrategy":"validation","validationCode":"if args.is_empty() {\n    eprintln!(\"Usage: f hash <paths or unstash./ args>\");\n    std::process::exit(2);\n}","typeGuard":"null","tryCatchPattern":"match hash::run(opts) {\n    Err(e) if e.to_string().starts_with(\"Usage:\") => {\n        eprintln!(\"{e}\");\n        std::process::exit(2); // usage error, distinct exit code\n    }\n    r => r?,\n}","preventionTips":["Check argument count in your wrapper before dispatching to subcommands","Quote globs properly so empty expansions are detected (`$#` count check in shell)","Always print usage text on empty args in CLI entrypoints","Use clap or a similar arg parser to get automatic usage enforcement"],"tags":["cli","usage","arguments","rust"],"backgroundTag":"missing-required-argument","analyzedSha":"a747e741ae92c09071d0ae946ab48488adcff1ce","analyzedAt":"2026-09-01T22:43:55.719Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}