github.com/joshdk/godel@v0.0.0-20170529232908-862138a45aee/cmd/githubwiki/cmd.go (about) 1 // Copyright 2016 Palantir Technologies, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package githubwiki 16 17 import ( 18 "github.com/palantir/pkg/cli" 19 "github.com/palantir/pkg/cli/flag" 20 ) 21 22 const ( 23 docsDirFlag = "docs-dir" 24 repoFlag = "repository" 25 authorNameFlag = "author-name" 26 authorEmailFlag = "author-email" 27 committerNameFlag = "committer-name" 28 committerEmailFlag = "committer-email" 29 msgFlag = "message" 30 ) 31 32 func Command() cli.Command { 33 return cli.Command{ 34 Name: "github-wiki", 35 Usage: "Push contents of a documents directory to a GitHub Wiki repository", 36 Flags: []flag.Flag{ 37 flag.StringFlag{Name: docsDirFlag, Usage: "Directory whose contents should be pushed to the GitHub Wiki repository", Required: true}, 38 flag.StringFlag{Name: repoFlag, Usage: "GitHub wiki repository address (for example, git@github.com:org/project.wiki.git)", Required: true}, 39 flag.StringFlag{Name: authorNameFlag, Usage: "Author name to use for commit (if blank, uses value of last commit in current project)"}, 40 flag.StringFlag{Name: authorEmailFlag, Usage: "Author email to use for commit (if blank, uses value of last commit in current project)"}, 41 flag.StringFlag{Name: committerNameFlag, Usage: "Committer name to use for commit (if blank, uses value of last commit in current project)"}, 42 flag.StringFlag{Name: committerEmailFlag, Usage: "Committer email to use for commit (if blank, uses value of last commit in current project)"}, 43 flag.StringFlag{Name: msgFlag, Usage: "Commit message to use for commit in GitHub Wiki repository", Value: `Sync documentation using godel github-wiki task ({{ printf "%.7s" .CommitID}})`}, 44 }, 45 Action: func(ctx cli.Context) error { 46 return SyncGitHubWiki(Params{ 47 DocsDir: ctx.String(docsDirFlag), 48 Repo: ctx.String(repoFlag), 49 AuthorName: ctx.String(authorNameFlag), 50 AuthorEmail: ctx.String(authorEmailFlag), 51 CommitterName: ctx.String(committerNameFlag), 52 CommitterEmail: ctx.String(committerEmailFlag), 53 Msg: ctx.String(msgFlag), 54 }, ctx.App.Stdout) 55 }, 56 } 57 }