Skip to content

Improve bosh scp -h#693

Merged
rkoster merged 4 commits into
mainfrom
improve_help_scp
Oct 11, 2025
Merged

Improve bosh scp -h#693
rkoster merged 4 commits into
mainfrom
improve_help_scp

Conversation

@ragaskar
Copy link
Copy Markdown
Contributor

  • It is non-obvious how to compose remote path references for the bosh scp command. This change provides a minimal example of a remote path reference (:/some/remote/path) when help for scp is invoked. This example should be sufficient to allow a user to guess at what this command wants in order to target a remote path. It directs users to the documentation for further examples (as there are some other "special" parameters one can use with these path arguments that are not enumerated in the CLI help).

Below is an example of the current help for PATH, followed by the new display after this patch is applied:

Existing help:

Usage:
  bosh [OPTIONS] scp [scp-OPTIONS] PATH...

SCP to/from instance(s)

https://bosh.io/docs/cli-v2#scp

Application Options:
  -v, --version                Show CLI version
      --config=                Config file path (default: ~/.bosh/config) [$BOSH_CONFIG]
  -e, --environment=           Director environment name or URL [$BOSH_ENVIRONMENT]
      --ca-cert=               Director CA certificate path or value [$BOSH_CA_CERT]
      --sha2                   Use SHA256 checksums [$BOSH_SHA2]
      --parallel=              The max number of parallel operations (default: 5)
      --client=                Override username or UAA client [$BOSH_CLIENT]
      --client-secret=         Override password or UAA client secret [$BOSH_CLIENT_SECRET]
  -d, --deployment=            Deployment name [$BOSH_DEPLOYMENT]
      --column=                Filter to show only given column(s), use the --column flag for each column you wish to include
      --json                   Output as JSON
      --tty                    Force TTY-like output [$BOSH_TTY]
      --no-color               Toggle colorized output
  -n, --non-interactive        Don't ask for user input [$BOSH_NON_INTERACTIVE]

Help Options:
  -h, --help                   Show this help message

[scp command options]
      -r, --recursive          Recursively copy entire directories. Note that symbolic links encountered are followed in the tree traversal
      -i, --private-key=       SSH using authorized key
      -l, --username=          Login name for authorized key (default: vcap)
          --gw-disable         Disable usage of gateway connection [$BOSH_GW_DISABLE]
          --gw-user=           Username for gateway connection [$BOSH_GW_USER]
          --gw-host=           Host for gateway connection [$BOSH_GW_HOST]
          --gw-private-key=    Private key path for gateway connection [$BOSH_GW_PRIVATE_KEY]
          --gw-socks5=         SOCKS5 URL [$BOSH_ALL_PROXY]
          --director           Target the command at the BOSH director (or other type of VM deployed via create-env)
          --agent-endpoint=    Address to connect to the agent's HTTPS endpoint (used with --director) [$BOSH_AGENT_ENDPOINT]
          --agent-certificate= CA certificate to validate the agent's HTTPS endpoint (used with --director) [$BOSH_AGENT_CERTIFICATE]

Proposed Update

(see PATH near end of output)

Usage:
  bosh [OPTIONS] scp [scp-OPTIONS] PATH...

SCP to/from instance(s)

https://bosh.io/docs/cli-v2#scp

Application Options:
  -v, --version                Show CLI version
      --config=                Config file path (default: ~/.bosh/config) [$BOSH_CONFIG]
  -e, --environment=           Director environment name or URL [$BOSH_ENVIRONMENT]
      --ca-cert=               Director CA certificate path or value [$BOSH_CA_CERT]
      --sha2                   Use SHA256 checksums [$BOSH_SHA2]
      --parallel=              The max number of parallel operations (default: 5)
      --client=                Override username or UAA client [$BOSH_CLIENT]
      --client-secret=         Override password or UAA client secret [$BOSH_CLIENT_SECRET]
  -d, --deployment=            Deployment name [$BOSH_DEPLOYMENT]
      --column=                Filter to show only given column(s), use the --column flag for each column you wish to include
      --json                   Output as JSON
      --tty                    Force TTY-like output [$BOSH_TTY]
      --no-color               Toggle colorized output
  -n, --non-interactive        Don't ask for user input [$BOSH_NON_INTERACTIVE]

Help Options:
  -h, --help                   Show this help message

[scp command options]
      -r, --recursive          Recursively copy entire directories. Note that symbolic links encountered are followed in the tree traversal
      -i, --private-key=       SSH using authorized key
      -l, --username=          Login name for authorized key (default: vcap)
          --gw-disable         Disable usage of gateway connection [$BOSH_GW_DISABLE]
          --gw-user=           Username for gateway connection [$BOSH_GW_USER]
          --gw-host=           Host for gateway connection [$BOSH_GW_HOST]
          --gw-private-key=    Private key path for gateway connection [$BOSH_GW_PRIVATE_KEY]
          --gw-socks5=         SOCKS5 URL [$BOSH_ALL_PROXY]
          --director           Target the command at the BOSH director (or other type of VM deployed via create-env)
          --agent-endpoint=    Address to connect to the agent's HTTPS endpoint (used with --director) [$BOSH_AGENT_ENDPOINT]
          --agent-certificate= CA certificate to validate the agent's HTTPS endpoint (used with --director) [$BOSH_AGENT_CERTIFICATE]

[scp command arguments]
  PATH:                        Strings referencing remote (e.g. ":/some/remote/path" -- "user@host" may be omitted) or local paths (e.g. "./some/local/path"). See CLI documentation for more examples.

- It is non-obvious how to compose remote path references for the `bosh
  scp` command. This change provides a minimal example of a remote path
  reference (`:/some/remote/path`) when help for scp is invoked.  This
  example should be sufficient to allow a user to guess at what this
  command wants in order to target a remote path. It directs users to
  the documentation for further examples (as there are some other
  "special" parameters one can use with these path arguments that are
  not enumerated in the CLI help).
@selzoc
Copy link
Copy Markdown
Member

selzoc commented Aug 19, 2025

I think it would be helpful to have an example of the more common case of scping from an instance/index or something

@ragaskar
Copy link
Copy Markdown
Contributor Author

I think it would be helpful to have an example of the more common case of scping from an instance/index or something

I agree, not sure this is the right place for it?

I think there's no existing hooks for invocation examples, and shoving a full invocation example into an argument description feels a bit weird to me.

The problem I was trying to solve here is I was like "OK, I know I want to bosh scp, and I'm familiar with scp, but how does this work when I don't have the username/host -- what am I supposed to do?". I think the remote path example provides enough of a hint to let you solve that problem.

That said, my use case was director-tied (I was trying to bosh scp --director :/some/remote/file ./to/my/local), and so if the remote path example is flat-out wrong for the common case of scp-ing from an instance, than I agree, it should be changed.

@selzoc
Copy link
Copy Markdown
Member

selzoc commented Aug 19, 2025

Right, in non-director cases it would be something like bosh scp diego-cell/0:/results.json /tmp

@aramprice aramprice moved this from Inbox to Pending Review | Discussion in Foundational Infrastructure Working Group Aug 21, 2025
@aramprice aramprice requested review from a team, a-hassanin and lnguyen and removed request for a team August 21, 2025 14:41
Comment thread cmd/opts/opts.go Outdated
lnguyen
lnguyen previously approved these changes Aug 25, 2025
@github-project-automation github-project-automation Bot moved this from Pending Review | Discussion to Pending Merge | Prioritized in Foundational Infrastructure Working Group Aug 25, 2025
Comment thread cmd/opts/opts.go Outdated

type SCPArgs struct {
Paths []string `positional-arg-name:"PATH"`
Paths []string `positional-arg-name:"PATH" description:"Strings referencing remote (e.g. \":/some/remote/path\" -- \"user@host\" may be omitted) or local paths (e.g. \"./some/local/path\"). See CLI documentation for more examples."`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actually IMHO I would rather name it differently:
Usage:
bosh [OPTIONS] scp [scp-OPTIONS] source ... target

The same way a typical scp command would also describe it. I see it is technically one array, but it better describes how it can actually be used

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ragaskar do you have any opinion on this?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@ragaskar - are you ok with switching the the scp style documentation, instead of the example-based version in this PR?

@rkoster rkoster moved this from Pending Merge | Prioritized to Pending Review | Discussion in Foundational Infrastructure Working Group Sep 4, 2025
@rkoster rkoster moved this from Pending Review | Discussion to Waiting for Changes | Open for Contribution in Foundational Infrastructure Working Group Sep 4, 2025
Co-authored-by: Alexander Lais <Alexander.lais@me.com>
rkoster
rkoster previously approved these changes Sep 25, 2025
@github-project-automation github-project-automation Bot moved this from Waiting for Changes | Open for Contribution to Pending Merge | Prioritized in Foundational Infrastructure Working Group Sep 25, 2025
Copy link
Copy Markdown
Member

@aramprice aramprice left a comment

Choose a reason for hiding this comment

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

@ragaskar - can you fix the lint errors?

@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Waiting for Changes | Open for Contribution in Foundational Infrastructure Working Group Oct 2, 2025
Replace unescaped backticks with single quotes in the struct tag
description to fix Go parser errors. Backticks within backtick-delimited
struct tags cause syntax errors.

Changes:
- Replace `instance-group/id` with (instance-group/id)
- Replace `bosh scp ...` with 'bosh scp ...'

Fixes linting errors identified in code review.
Fix linting errors in improve_help_scp branch
@rkoster
Copy link
Copy Markdown
Contributor

rkoster commented Oct 10, 2025

@aramprice are you okey with merging now that the checks are passing?

@github-project-automation github-project-automation Bot moved this from Waiting for Changes | Open for Contribution to Pending Merge | Prioritized in Foundational Infrastructure Working Group Oct 10, 2025
@rkoster rkoster merged commit fb1abe2 into main Oct 11, 2025
9 checks passed
@github-project-automation github-project-automation Bot moved this from Pending Merge | Prioritized to Done in Foundational Infrastructure Working Group Oct 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

8 participants