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

Adding version flag #31

Merged
merged 1 commit into from
Dec 20, 2017
Merged

Adding version flag #31

merged 1 commit into from
Dec 20, 2017

Conversation

Lucas-C
Copy link

@Lucas-C Lucas-C commented Jul 8, 2017

No description provided.

Copy link
Member

@stardust85 stardust85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the Python 2.x compatibility of your change and then I can merge it.

self.parser.add_argument("-D", "--debug", action="store_true", dest="debug", default=False,
help="Print lots of debugging information")
self.parser.add_argument("-D", "--debug", action="store_true", help="Print lots of debugging information")
self.parser.add_argument("-V", action="store_true", dest="display_version", help="Prints version and exit")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add also long form --version if you want is as an option.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.repository = None

def run(self, args=None):
args_namespace = self.parser.parse_args(args)
if args_namespace.display_version:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This functionality didn't work for me in Python 2.6 or 2.7 for some reason. It exited, but didn't print anything.

Please try a solution working also in python >= 2.6

Copy link
Author

@Lucas-C Lucas-C Jul 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works for me with Python 2.7, but you have to feed the subparser:

$ artifact -V get-metadata X Y
repositorytools v4.2.2

This is due to a bug / change in argparse between Python 2 & 3: https://stackoverflow.com/a/24211480/636849
I haven't found any easy workaround so far. The error is raised here: https://github.com/python/cpython/blob/2.7/Lib/argparse.py#L1949

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't like this behaviour, feel free to ignore this PR, and potentially include this feature by yourself later on.
This commit was only planned as a minor improvement, I don't think it's worth a convoluted workaround :)

@@ -55,5 +58,5 @@ def run(self, args=None):
return args_namespace.func(args_namespace)

def __call__(self, *args):
self.run(args)
self.run(*args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged in #30, but you can probably keep it here, because github doesn't complain about it ;)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that was expected. I left this commit so that this adding_version_flag branch could be merged once you included the *args fix.

@Lucas-C
Copy link
Author

Lucas-C commented Dec 15, 2017

I rebased this PR. Is this ok for you ?

@stardust85
Copy link
Member

stardust85 commented Dec 20, 2017

Hi, please merge my changes from today to your branch. They fix broken python2.6 and python 3.3 tests. Btw, would you mind if I gave you r/w access to repositorytools? :)

@Lucas-C
Copy link
Author

Lucas-C commented Dec 20, 2017

Done
And no, I won't mind, but don't expect me to be able to dedicate much time to this project :)

@stardust85 stardust85 merged commit e9db257 into packagemgmt:master Dec 20, 2017
@stardust85
Copy link
Member

OK, I sent you an invitation to packagemanagement organization.

@Lucas-C Lucas-C deleted the adding_version_flag branch October 26, 2022 12:56
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