-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from hashtagchris/issue2
Honor repo flag on sync
- Loading branch information
Showing
60 changed files
with
21,789 additions
and
133 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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,31 @@ | ||
package src | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// flags common to pull, push and sync operations | ||
type CommonFlags struct { | ||
CacheDir, RepoName, RepoNameList, RepoNameListFile string | ||
} | ||
|
||
func (f *CommonFlags) Init(cmd *cobra.Command) { | ||
cmd.Flags().StringVar(&f.CacheDir, "cache-dir", "", "Directory containing the repopositories cache created by the `pull` command") | ||
_ = cmd.MarkFlagRequired("cache-dir") | ||
|
||
cmd.Flags().StringVar(&f.RepoName, "repo-name", "", "Single repository name to pull") | ||
cmd.Flags().StringVar(&f.RepoNameList, "repo-name-list", "", "Comma delimited list of repository names to pull") | ||
cmd.Flags().StringVar(&f.RepoNameListFile, "repo-name-list-file", "", "Path to file containing a list of repository names to pull") | ||
} | ||
|
||
func (f *CommonFlags) Validate(reposRequired bool) Validations { | ||
var validations Validations | ||
if reposRequired && !f.HasAtLeastOneRepoFlag() { | ||
validations = append(validations, "one of --repo-name, --repo-name-list, --repo-name-list-file must be set") | ||
} | ||
return validations | ||
} | ||
|
||
func (f *CommonFlags) HasAtLeastOneRepoFlag() bool { | ||
return f.RepoName != "" || f.RepoNameList != "" || f.RepoNameListFile != "" | ||
} |
This file contains 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 was deleted.
Oops, something went wrong.
Oops, something went wrong.