Package: negargparse
negargparseAn ArgumentParser which understands negative numbers.GettingnegargparseThe preferred way to usenegargparseis to copy the modulenegargparse.pyinto your project. This is because currently one can expect frequent API changes. We do usesemantic versioningto help you guard against it.negargparsecan also  be installed from PyPI:pipinstallnegargparseUsageTheargparsemodule in python provides tools to parse command line arguments. However, sometimes it doesn't interpret arguments correctly when dealing with negative numbers. Currentlyargparsecorrectly interprets negative numbers if they are strictly numbers and there are no numeral options like-1. However it doesn't work when working with non standard numeral formats. e.g. declination is usually written in the(+|-)(degree):(arcminute):(arcsecond)format like-16:32:45.46.argparsewould interpret this as an option, rather than an argument and quit (because of finding an unknown argument) before we have a chance to examine it. Any way to solve this issue requires doing some hacky gymnastics,negargparseis here to do that for you.negargparseprovides a subclass ofArgumentParsercalledNegativeArgumentParser, which escapes all arguments which begin with a '-' followed by a digit. Now declare the type of arguments that you expect to be negative as one of the provided typesNegString,NegInt,NegFloatto unescape them.>>>parser=negargparse.NegativeArgumentParser()>>>parser.add_argument("eggs",type=NegString)>>>parser.parse_args(["-23h15m04s"])Namespace(eggs='-23h15m04s')LicenseThis repository is distributed under the MIT License, though the module is available under the more permissive MIT-0 license. See theLICENSEor at the top of themodulefor the license text.Known issuesRight now this project is more or less a framework to develop the module. Except for some narrow cases, it breaks more pre-existing functionality ofargparsethan provide new ones. Right now you are better off not using this if that bothers you.If the user types a negative number in an unexpected (not of the provided NegString etc. types) argument, this would escape the said field, but since it is not declared as a NegString/NegInt/NegFloat, it wouldn't be unescaped.This module doesn't respect the POSIX convention of leaving the arguments after--.Currently single digit options are unusable.This project currently lacks support for versions earlier than python 3.7. This is not because of lack of any features in python 3.6, but because of lack of support for annotations used in this module. At the release of v1, a special untyped release for python 3.6 shall be made.DevelopmentThis section tells you how to set up the development environment and run tests, which can be used to either modify the module for their own purpose of for potential contributors.Setup development environmentEnsurepython>= 3.8Ensure you havepoetryinstalled. You can get it fromhttps://github.com/python-poetry/poetry. This requirespoetry>=1.2 which is currently only released as alpha.Clone the repositoryInstall the packagepoetryinstall--withdevInstall pre-commit hookspoetryrunpre-commitinstallNow whenever developing, enter virtual environment usingpoetryshellFrom now on this document assumes that you are within a virtual environment. Otherwise prepend you commands withpoetry run.TestingTests are written in thepytestframework, to run them use:pytestTo run extensive tests within isolated environments usetox:toxLinksChange logContributing