Skip to content
Open
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
5 changes: 5 additions & 0 deletions .changeset/tame-rabbits-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@googleworkspace/cli": patch
---

Document `unmasked` flag for `gws auth export`
2 changes: 2 additions & 0 deletions src/auth_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ pub async fn handle_auth_command(args: &[String]) -> Result<(), GwsError> {
" --login Run `gws auth login` after successful setup\n",
" status Show current authentication state\n",
" export Print decrypted credentials to stdout\n",
" --unmasked Print full credentials including secrets (default: masked)\n",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Thank you for adding the documentation. While reviewing, I noticed the argument parsing for the export subcommand is fragile and can lead to incorrect behavior (e.g., --help is not handled, extra arguments are ignored).

For improved robustness and consistency with other subcommands, I recommend enhancing the parsing logic. Here's a suggestion to handle --help and make flag detection more flexible:

        "export" => {
            let sub_args = &args[1..];
            if sub_args.iter().any(|a| a == "--help" || a == "-h") {
                println!("Usage: gws auth export [--unmasked]\n\n  Print decrypted credentials to stdout.\n\nFLAGS:\n    --unmasked    Print full credentials including secrets (default: masked)");
                return Ok(());
            }
            let unmasked = sub_args.iter().any(|arg| arg == "--unmasked");
            handle_export(unmasked).await
        }

A dedicated parsing function for export arguments, similar to login and setup, would be an even better long-term solution.

" logout Clear saved credentials and token cache",
);

Expand Down Expand Up @@ -397,6 +398,7 @@ async fn fetch_userinfo_email(access_token: &str) -> Option<String> {
.map(|s| s.to_string())
}

/// Export credentials to stdout
async fn handle_export(unmasked: bool) -> Result<(), GwsError> {
let enc_path = credential_store::encrypted_credentials_path();
if !enc_path.exists() {
Expand Down
Loading