-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c313ab3
commit 800d694
Showing
6 changed files
with
66 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -14,5 +14,6 @@ var Command = cli.Command{ | |
repoRemoveCmd, | ||
repoRepairCmd, | ||
repoChownCmd, | ||
repoSyncCmd, | ||
}, | ||
} |
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,49 @@ | ||
package repo | ||
|
||
import ( | ||
"os" | ||
"text/template" | ||
|
||
"github.com/drone/drone-cli/drone/internal" | ||
"github.com/urfave/cli" | ||
) | ||
|
||
var repoSyncCmd = cli.Command{ | ||
Name: "sync", | ||
Usage: "synchronize the repository list", | ||
ArgsUsage: " ", | ||
Action: repoSync, | ||
Flags: []cli.Flag{ | ||
cli.StringFlag{ | ||
Name: "format", | ||
Usage: "format output", | ||
Value: tmplRepoList, | ||
}, | ||
}, | ||
} | ||
|
||
func repoSync(c *cli.Context) error { | ||
client, err := internal.NewClient(c) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
repos, err := client.RepoListOpts(true, true) | ||
if err != nil || len(repos) == 0 { | ||
return err | ||
} | ||
|
||
tmpl, err := template.New("_").Parse(c.String("format") + "\n") | ||
if err != nil { | ||
return err | ||
} | ||
|
||
org := c.String("org") | ||
for _, repo := range repos { | ||
if org != "" && org != repo.Owner { | ||
continue | ||
} | ||
tmpl.Execute(os.Stdout, repo) | ||
} | ||
return nil | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.