resticprofile
resticprofile copied to clipboard
Add --help to own commands (e.g. generate --help)
Quick PR: Adds resticprofile OWNCOMMAND --help and resticprofile --help -v to display flags for own commands.
Had played a bit with the new restic version today and couldn't remember some flags of rp own commands... thought we should support cli --help there. Output could probably be formatted in a nicer way but it is better than nothing.
E.g.:
➜ resticprofile generate -h
resticprofile own command:
generate generate resources (--random-key [size], --bash-completion & --zsh-completion)
flags:
--bash-completion generate a shell completion script for bash
--random-key generate a cryptographically secure random key to use as a restic keyfile
--zsh-completion generate a shell completion script for zsh
resticprofile --help -v
Usage of resticprofile:
resticprofile [resticprofile flags] [profile name.][restic command] [restic flags]
resticprofile [resticprofile flags] [profile name.][resticprofile command] [command specific flags]
resticprofile flags:
-c, --config string configuration file (default "profiles")
--dry-run display the restic commands instead of running them
-f, --format string file format of the configuration (default is to use the file extension)
-h, --help display this help
--lock-wait duration wait up to duration to acquire a lock (syntax "1h5m30s")
-l, --log string logs to a target instead of the console
-n, --name string profile name (default "default")
--no-ansi disable ansi control characters (disable console colouring)
--no-lock skip profile lock file
--no-prio don't set any priority on load: used when started from a service that has already set the priority
-q, --quiet display only warnings and errors
--theme string console colouring theme (dark, light, none) (default "light")
--trace display even more debugging information
-v, --verbose display some debugging information
-w, --wait wait at the end until the user presses the enter key
resticprofile own commands:
version display version (run in verbose mode for detailed information)
flags:
-v, --verbose display details information
self-update update to latest resticprofile (use -q/--quiet flag to update without confirmation)
flags:
-q, --quiet update without confirmation prompt
profiles display profile names from the configuration file
show show all the details of the current profile
schedule schedule jobs from a profile (use --all flag to schedule all jobs of all profiles)
flags:
--all add all scheduled jobs of all profiles
--no-start don't start the timer/service (systemd/launch only)
unschedule remove scheduled jobs of a profile (use --all flag to unschedule all profiles)
flags:
--all remove all scheduled jobs of all profiles
status display the status of scheduled jobs (use --all flag for all profiles)
flags:
--all display the status of all scheduled jobs of all profiles
generate generate resources (--random-key [size], --bash-completion & --zsh-completion)
flags:
--bash-completion generate a shell completion script for bash
--random-key generate a cryptographically secure random key to use as a restic keyfile
--zsh-completion generate a shell completion script for zsh
Documentation available at https://creativeprojects.github.io/resticprofile/
Codecov Report
Base: 72.88% // Head: 72.06% // Decreases project coverage by -0.81% :warning:
Coverage data is based on head (
eaa5056) compared to base (0c43c2c). Patch coverage: 44.65% of modified lines in pull request are covered.
Additional details and impacted files
@@ Coverage Diff @@
## master #139 +/- ##
==========================================
- Coverage 72.88% 72.06% -0.82%
==========================================
Files 74 75 +1
Lines 7225 7504 +279
==========================================
+ Hits 5266 5408 +142
- Misses 1745 1875 +130
- Partials 214 221 +7
| Impacted Files | Coverage Δ | |
|---|---|---|
| term/term.go | 42.85% <0.00%> (-8.58%) |
:arrow_down: |
| commands_display.go | 40.18% <40.18%> (ø) |
|
| flags.go | 96.05% <85.71%> (+9.80%) |
:arrow_up: |
| commands.go | 55.03% <91.42%> (+7.46%) |
:arrow_up: |
| complete.go | 100.00% <100.00%> (ø) |
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.
:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.
Yes this is a good idea.
We could also support resticprofile help generate since it is a rather common pattern as well as resticprofile generate -h
... and maybe we could also permit to pass the help through to restic: for now a resticprofile backup -h is trying to load a default profile before calling restic, and fails if it didn't find a configuration file.
I’ll update the PR this week.
If we add a help command that also forwards to restic help, I think we could display what flags the different profiles define (if any), so that the normal help of restic is extended with the config that resticprofile applies.
Oh yes, good idea, I do like that 👍🏻
@creativeprojects, the last week in Aug was longer than expected :) ... let me know what you think.
the last week in Aug was longer than expected
I know that feeling 😄
So far it looks good to me.
I noticed that we need to escape the % though, if you try a help prune you get a (MISSING) after a %:
% ./resticprofile help prune
The "prune" command checks the repository and removes data that is not
referenced and therefore not needed any more.
EXIT STATUS
===========
Exit status is 0 if the command was successful, and non-zero if there was any error.
Usage:
resticprofile [resticprofile flags] [profile name.]prune [flags]
Flags:
-n, --dry-run do not modify the repository, just print what would be done
-h, --help help for prune
--max-repack-size size maximum size to repack (allowed suffixes: k/K, m/M, g/G, t/T)
--max-unused limit tolerate given limit of unused data (absolute value in bytes with suffixes k/K, m/M, g/G, t/T, a value in
%!o(MISSING)r the word 'unlimited') (default "5%!"(MISSING))
--repack-cacheable-only only repack packs which are cacheable
--repack-small repack pack files below 80%!o(MISSING)f target pack size
--repack-uncompressed repack all uncompressed data
--unsafe-recover-no-free-space string UNSAFE, READ THE DOCUMENTATION BEFORE USING! Try to recover a repository stuck with no free space. Do not use
without trying out 'prune --max-repack-size 0' first.
...
Have added the missing unit test. Should be fixed now.