Skip to content

gmail attachment: --name flag silently ignored when --out is provided #222

@schickling

Description

@schickling

Problem

When using gog gmail attachment <messageId> <attachmentId> --out /tmp/ --name invoice.pdf, the --name flag is silently ignored because --out is set. The tool treats /tmp/ (a directory) as the output file path instead of combining the directory with the filename.

The CLI struct documents this behavior:

Name string `name:"name" help:"Filename (only used when --out is empty)"`

But this is surprising and leads to downstream bugs (see #related issue about caching).

Expected behavior

Either:

  1. When --out is a directory, combine it with --name to form the full path (e.g. /tmp/ + invoice.pdf/tmp/invoice.pdf), or
  2. Error clearly when --out is a directory path, telling the user to provide a full file path

Reproduction

gog gmail attachment <messageId> <attachmentId> --out /tmp/ --name invoice.pdf
# Output: path=/tmp/ cached=true bytes=512
# Expected: path=/tmp/invoice.pdf cached=false bytes=<actual size>

The output path=/tmp/ and bytes=512 (the directory metadata size) confirms that /tmp/ itself is being treated as the target file.


Filed by an AI agent on behalf of @schickling

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions