Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting of restic options command #3192

Merged
merged 1 commit into from
Dec 23, 2020

Conversation

DRON-666
Copy link
Contributor

What does this PR change? What problem does it solve?

Printf in cmd_options.go uses fixed (%-15s) formatting to simulate two-column table of extended options.
This PR adds code to dynamically calculate the column width based on the longest option name.

Before:

All Extended Options:
  azure.connections   set a limit for the number of concurrent connections (default: 20)
  b2.connections    set a limit for the number of concurrent connections (default: 5)
  gs.connections    set a limit for the number of concurrent connections (default: 20)
  local.layout      use this backend directory layout (default: auto-detect)
  rclone.args       arguments for running rclone (default: serve restic --stdio --b2-hard-delete)
  rclone.connections   set a limit for the number of concurrent connections (default: 5)
  rclone.program    path to rclone (default: rclone)
  rest.connections   set a limit for the number of concurrent connections (default: 5)
  s3.bucket-lookup   bucket lookup style: 'auto', 'dns', or 'path'
  s3.connections    set a limit for the number of concurrent connections (default: 5)
  s3.layout         use this backend layout (default: auto-detect)
  s3.list-objects-v1   use deprecated V1 api for ListObjects calls
  s3.region         set region
  s3.retries        set the number of retries attempted
  s3.storage-class   set S3 storage class (STANDARD, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING or REDUCED_REDUNDANCY)
  sftp.command      specify command to create sftp connection
  sftp.layout       use this backend directory layout (default: auto-detect)
  swift.connections   set a limit for the number of concurrent connections (default: 5)

After:

All Extended Options:
  azure.connections   set a limit for the number of concurrent connections (default: 20)
  b2.connections      set a limit for the number of concurrent connections (default: 5)
  gs.connections      set a limit for the number of concurrent connections (default: 20)
  local.layout        use this backend directory layout (default: auto-detect)
  rclone.args         arguments for running rclone (default: serve restic --stdio --b2-hard-delete)
  rclone.connections  set a limit for the number of concurrent connections (default: 5)
  rclone.program      path to rclone (default: rclone)
  rest.connections    set a limit for the number of concurrent connections (default: 5)
  s3.bucket-lookup    bucket lookup style: 'auto', 'dns', or 'path'
  s3.connections      set a limit for the number of concurrent connections (default: 5)
  s3.layout           use this backend layout (default: auto-detect)
  s3.list-objects-v1  use deprecated V1 api for ListObjects calls
  s3.region           set region
  s3.retries          set the number of retries attempted
  s3.storage-class    set S3 storage class (STANDARD, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING or REDUCED_REDUNDANCY)
  sftp.command        specify command to create sftp connection
  sftp.layout         use this backend directory layout (default: auto-detect)
  swift.connections   set a limit for the number of concurrent connections (default: 5)

Also PR #3085 adds bool support to options package, but without a corresponding test. This has been fixed too.

And the last change fixes reuse of the err variable in TestOptionsApplyInvalid, which can lead to panic instead of test failure.

Was the change discussed in an issue or in the forum before?

No, but this PR based on first commit of #3067.

Checklist

  • I have read the Contribution Guidelines
  • I have enabled maintainer edits for this PR
  • I have added tests for all changes in this PR
    - [x] I have added documentation for the changes (in the manual)
    - [x] There's a new file in changelog/unreleased/ that describes the changes for our users (template here)
  • I have run gofmt on the code in all commits
  • All commit messages are formatted in the same style as the other commits in the repo
  • I'm done, this Pull Request is ready for review

Add tests for bool type.
Fix subtle bug in TestOptionsApplyInvalid.
Fix options list formatting.
Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for the cleanup. It looks much nicer like that!

@MichaelEischer MichaelEischer merged commit 9c41e4a into restic:master Dec 23, 2020
@DRON-666 DRON-666 deleted the fix-options branch December 23, 2020 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants