Skip to content

Commit

Permalink
Expand in-app help
Browse files Browse the repository at this point in the history
  • Loading branch information
maetthu committed Feb 21, 2021
1 parent 38b50d7 commit d54c2d9
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 25 deletions.
42 changes: 20 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,35 @@ $ export GITHUB_TOKEN="your-personal-access-token"
## Usage

```
Usage:
ghupload upload <local-path> <remote-url> [flags]
Flags:
-b, --branch string Commit to branch (default branch if empty)
-h, --help help for upload
-m, --message string Commit message (required)
```
_local-path_ is either a path to a local file or "-" for STDIN.
Uploads (commits) a local file to a github repository
_remote-url_ can be one of the following formats and has to include the repository owner, the repository and the path to the file inside the repository:
<local-path> is either a path to a local file or - for STDIN.
<remote-url> can be one of the following formats and has to include the repository owner, the repository and the path to the file inside the repository:
* https://github.com/owner/repository/path/in/repo
* git@github.com:owner/repository.git/path/in/repo
* owner/repository/path/in/repo
### Examples

* Upload file
Command prints the commit SHA on success.
```shell
$ ghupload upload -m "commit msg" README.md invit/ghupload/README.md
```
Usage:
ghupload upload -m <commit-msg> [-b <branch>] <local-path> <remote-url>
Examples:
* Upload local file
$ ghupload upload -m "commit msg" README.md owner/repository/README.md
b6cbb5b2ea041956c4ac8da17007f95d2312a461
* Upload data from STDIN
$ ghupload upload -m "commit msg" - owner/repository/README.md
this is the new
content
of the file
^D
3be39e60c3ae44faa40f4efc31241f3564c396f1
```shell
$ ghupload upload -m "commit msg" - invit/ghupload/README.md
this is the new
content
of the file
^D
Flags:
-b, --branch string Commit to branch (default branch if empty)
-h, --help help for upload
-m, --message string Commit message (required)
```

## Build
Expand Down
27 changes: 24 additions & 3 deletions cmd/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,30 @@ func init() {
}

var uploadCmd = &cobra.Command{
Use: "upload <local-path> <remote-url>",
Short: "Uploads file to github repository",
Args: cobra.ExactArgs(2),
Use: "upload -m <commit-msg> [-b <branch>] <local-path> <remote-url>",
DisableFlagsInUseLine: true,
Short: "Uploads file to github repository",
Long: "Uploads (commits) a local file to a github repository\n" +
"\n" +
"<local-path> is either a path to a local file or - for STDIN.\n" +
"<remote-url> can be one of the following formats and has to include the repository owner, " +
"the repository and the path to the file inside the repository:\n" +
"* https://github.com/owner/repository/path/in/repo\n" +
"* git@github.com:owner/repository.git/path/in/repo\n" +
"* owner/repository/path/in/repo\n" +
"\n" +
"Command prints the commit SHA on success.",
Example: "* Upload local file\n" +
" $ ghupload upload -m \"commit msg\" README.md owner/repository/README.md\n" +
" b6cbb5b2ea041956c4ac8da17007f95d2312a461\n" +
"* Upload data from STDIN\n" +
" $ ghupload upload -m \"commit msg\" - owner/repository/README.md\n" +
" this is the new \n" +
" content \n" +
" of the file\n" +
" ^D\n" +
" 3be39e60c3ae44faa40f4efc31241f3564c396f1",
Args: cobra.ExactArgs(2),
PreRunE: func(cmd *cobra.Command, args []string) error {
if os.Getenv("GITHUB_TOKEN") == "" {
return errors.New("Missing GITHUB_TOKEN environment variable")
Expand Down

0 comments on commit d54c2d9

Please sign in to comment.