Skip to content
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

Improve argument parsing, fix style #3

Merged
merged 35 commits into from
Feb 10, 2017

Conversation

jcfr
Copy link
Collaborator

@jcfr jcfr commented Feb 1, 2017

In addition of fixing some stylistic issues, this PR also implements the following features:

  • proper parsing of command line argument for both github-release and github-asset executable
  • support for GITHUB_TOKEN environment variable as an alternative to the ~/.netrc
  • support for "single cli" usage either as an installed executable (githubrelease) or directly using github_release.py script:
$ githubrelease
usage: githubrelease [-h] {release, asset} ...

positional arguments:
    {release, asset}
                        sub-command help
    release             Manage releases (list, create, delete, ...)
    asset               Manage release assets (upload, download, ...)

optional arguments:
  -h, --help            show this help message and exit
githubrelease: error: too few arguments
$ githubrelease release
usage: githubrelease release [-h]
                             repo_name
                             {info,release-notes,debug,create,unpublish,list,publish,delete}
                             ...
githubrelease release: error: too few arguments
$ githubrelease release --help
usage: githubrelease release [-h]
                             repo_name
                             {info,release-notes,debug,create,unpublish,list,publish,delete}
                             ...

positional arguments:
  repo_name
  {info,release-notes,debug,create,unpublish,list,publish,delete}
                        sub-command help
    info                Get release description
    release-notes       Set release notes
    debug               Print release detailed information
    create              Create a release
    unpublish           Unpublish a release setting draft to 'True'
    list                List releases
    publish             Publish a release setting draft to 'False'
    delete              Delete a release

optional arguments:
  -h, --help            show this help message and exit
$ githubrelease asset
usage: githubrelease asset [-h] repo_name {download,erase,upload,delete} ...
githubrelease asset: error: too few arguments
$ githubrelease asset --help
usage: githubrelease asset [-h] repo_name {download,erase,upload,delete} ...

positional arguments:
  repo_name
  {download,erase,upload,delete}
                        sub-command help
    download            Download release assets
    erase               Delete release assets
    upload              Upload release assets
    delete              Delete release assets

optional arguments:
  -h, --help            show this help message and exit

@jcfr jcfr changed the title Improve argument parsing Improve argument parsing, fix style Feb 1, 2017
@jcfr jcfr force-pushed the improve-argument-parsing branch 2 times, most recently from 61dcec8 to 94de874 Compare February 2, 2017 05:08
@jcfr jcfr force-pushed the improve-argument-parsing branch 3 times, most recently from a8a630c to d4b30c0 Compare February 2, 2017 05:29
…set"

* Install new executable named "githubrelease" supporting both
  "release" and "asset" commands.
* Support for directly use of "github_release.py"
* Multi-parser usage was adapted from https://chase-seibert.github.io/blog/2014/03/21/python-multilevel-argparse.html

Examples:

  python github_release.py release j0057/iplbapi list
  githubrelease release j0057/iplbapi list
  githubrelease asset j0057/iplbapi download
@jcfr
Copy link
Collaborator Author

jcfr commented Feb 2, 2017

@j0057 @jnweiger This PR should address some of the usability concern.

If you prefer, I could split the PR in multiple PRs. If the proposed the change looks good, I will look into updating the documentation.

This allows to directly create a pre-release
This will be useful to support command parameter with dashes (e.g --do-foo).
It ensures that the corresponding value is retrieved using `do_foo`.
…eter

When specified, github_release does not upload or erase packages but
acts like it was done.
When specified, matching packages will be excluded from the subset already
matched by the provided selection "pattern".
@j0057 j0057 merged commit bc24d78 into scikit-build:master Feb 10, 2017
jcfr added a commit that referenced this pull request Feb 11, 2017
Here are few examples of output:

```
$ githubrelease release jcfr/sandbox list

release 'nightly' info
  Tag name      : nightly
  Name          : nightly (updated on 20170212)
  ID            : 5427736
  Created       : 2017-02-01T07:31:19Z
  URL           : https://github.com/jcfr/sandbox/releases/tag/nightly
  Author        : jcfr
  Is published  : True
  Is prerelease : True

  Asset #0
    name      : sandbox-4.12.0.dev20170212-cp27-cp27m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp27-cp27m-win32.whl
    Downloads : 0

  Asset #1
    name      : sandbox-4.12.0.dev20170212-cp27-cp27m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp27-cp27m-win_amd64.whl
    Downloads : 0

  Asset #2
    name      : sandbox-4.12.0.dev20170212-cp34-cp34m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp34-cp34m-win32.whl
    Downloads : 0

  Asset #3
    name      : sandbox-4.12.0.dev20170212-cp34-cp34m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp34-cp34m-win_amd64.whl
    Downloads : 0

  Asset #4
    name      : sandbox-4.12.0.dev20170212-cp35-cp35m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp35-cp35m-win32.whl
    Downloads : 0

  Asset #5
    name      : sandbox-4.12.0.dev20170212-cp35-cp35m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp35-cp35m-win_amd64.whl
    Downloads : 0

  Asset #6
    name      : sandbox-4.12.0.dev20170212-cp36-cp36m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp36-cp36m-win32.whl
    Downloads : 0

  Asset #7
    name      : sandbox-4.12.0.dev20170212-cp36-cp36m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp36-cp36m-win_amd64.whl
    Downloads : 0
```

```
$ githubrelease ref jcfr/sandbox list --verbose
Reference 'refs/heads/master'
  Object
    type : commit
    sha  : 0616014562f225a86469fffe39219536a53b56b1

Reference 'refs/tags/nightly'
  Object
    type : commit
    sha  : 0616014562f225a86469fffe39219536a53b56b1


```

```
$ githubrelease release jcfr/sandbox create my-tag
created 'my-tag' release
  Tag name      : my-tag
  ID            : 5427757
  Created       : 2017-02-11T06:23:39Z
  URL           : https://github.com/jcfr/sandbox/releases/tag/untagged-cfccf5564b71b4d4a2a0
  Author        : jcfr
  Is published  : False
  Is prerelease : False
```
jcfr added a commit that referenced this pull request Feb 11, 2017
Here are few examples of output:

```
$ githubrelease release jcfr/sandbox list

release 'nightly' info
  Tag name      : nightly
  Name          : nightly (updated on 20170212)
  ID            : 5427736
  Created       : 2017-02-01T07:31:19Z
  URL           : https://github.com/jcfr/sandbox/releases/tag/nightly
  Author        : jcfr
  Is published  : True
  Is prerelease : True

  Asset #0
    name      : sandbox-4.12.0.dev20170212-cp27-cp27m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp27-cp27m-win32.whl
    Downloads : 0

  Asset #1
    name      : sandbox-4.12.0.dev20170212-cp27-cp27m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp27-cp27m-win_amd64.whl
    Downloads : 0

  Asset #2
    name      : sandbox-4.12.0.dev20170212-cp34-cp34m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp34-cp34m-win32.whl
    Downloads : 0

  Asset #3
    name      : sandbox-4.12.0.dev20170212-cp34-cp34m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp34-cp34m-win_amd64.whl
    Downloads : 0

  Asset #4
    name      : sandbox-4.12.0.dev20170212-cp35-cp35m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp35-cp35m-win32.whl
    Downloads : 0

  Asset #5
    name      : sandbox-4.12.0.dev20170212-cp35-cp35m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp35-cp35m-win_amd64.whl
    Downloads : 0

  Asset #6
    name      : sandbox-4.12.0.dev20170212-cp36-cp36m-win32.whl
    size      : 52
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp36-cp36m-win32.whl
    Downloads : 0

  Asset #7
    name      : sandbox-4.12.0.dev20170212-cp36-cp36m-win_amd64.whl
    size      : 56
    uploader  : jcfr
    URL       : https://github.com/jcfr/sandbox/releases/download/nightly/sandbox-4.12.0.dev20170212-cp36-cp36m-win_amd64.whl
    Downloads : 0
```

```
$ githubrelease ref jcfr/sandbox list --verbose
Reference 'refs/heads/master'
  Object
    type : commit
    sha  : 0616014562f225a86469fffe39219536a53b56b1

Reference 'refs/tags/nightly'
  Object
    type : commit
    sha  : 0616014562f225a86469fffe39219536a53b56b1


```

```
$ githubrelease release jcfr/sandbox create my-tag
created 'my-tag' release
  Tag name      : my-tag
  ID            : 5427757
  Created       : 2017-02-11T06:23:39Z
  URL           : https://github.com/jcfr/sandbox/releases/tag/untagged-cfccf5564b71b4d4a2a0
  Author        : jcfr
  Is published  : False
  Is prerelease : False
```
@jcfr jcfr deleted the improve-argument-parsing branch April 4, 2017 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants