Repository navigation
CLI: move sync, list, shell, dash under jobs (breaking)
#95
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
Open
aflanagan
wants to merge
6
commits into
master
Choose a base branch
from
agent/jobs-subcommands-9623
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
693c512
Move sync, list, shell, and dash under jobs
cursoragent c36328d
Fix jobs unknown-command exit and shrink auto-discover writer
cursoragent 85996ac
Keep the opt-in discover rewrite when the line is not monitorable
cursoragent f436533
Write one fresh opt-in discover line instead of rewriting argv
cursoragent 760790e
Remove the hidden auto-discover opt-in
cursoragent 65ace4b
Match only the installed auto-discover line
cursoragent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package cmd | ||
|
|
||
| import ( | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| // jobsCmd groups the commands that read or change cron jobs on this machine. | ||
| // sync, list, shell, and dash are only available here. The root command does | ||
| // not keep those names as aliases or hidden forwarders. | ||
| var jobsCmd = &cobra.Command{ | ||
| Use: "jobs", | ||
| Short: "Sync, list, and run the cron jobs on this machine", | ||
| Long: `Commands for the cron jobs on this machine. | ||
|
|
||
| $ cronitor jobs sync | ||
| > Add monitoring to new cron jobs and sync changes | ||
|
|
||
| $ cronitor jobs list | ||
| > List cron jobs | ||
|
|
||
| $ cronitor jobs shell | ||
| > Run commands from a cron-like shell | ||
|
|
||
| $ cronitor jobs dash | ||
| > Start the web dashboard | ||
|
|
||
| sync accepts the alias discover: | ||
| $ cronitor jobs discover`, | ||
| // Cobra 1.2 only reports an unknown command for the root. A parent with | ||
| // subcommands and no Run prints help and exits 0. NoArgs runs once Run | ||
| // makes the command runnable, so `jobs <typo>` fails the way a root typo does. | ||
| // Bare `jobs` still prints help. | ||
| Args: cobra.NoArgs, | ||
| Run: func(cmd *cobra.Command, args []string) { | ||
| cmd.Help() | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| RootCmd.AddCommand(jobsCmd) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Non-blocking:
jobshas noRun/Args, so an unknown subcommand exits 0 and prints the group help on stdout:The root now rejects
syncwith exit 1, so a typo under the new path is quieter than the removed path. It also interacts with the documentedout=$(cronitor jobs sync --auto file) && printf '%s\n' "$out" | crontab -pattern if someone drops the flags.monitorandissuealready exit 1 here;groupandauthdon't, so the repo is mixed. Consider addingArgs: cobra.NoArgs(or aRunEthat returns an unknown-command error) sojobs <typo>fails likecronitor <typo>.