new command: systemlist
Runs an EDSM search query for systems starting with the given string.
This commit is contained in:
parent
6d4ee49011
commit
a3069a4c6a
4 changed files with 39 additions and 3 deletions
18
README.md
18
README.md
|
@ -34,7 +34,9 @@ optional arguments:
|
||||||
## explorationtools.py ##
|
## explorationtools.py ##
|
||||||
|
|
||||||
```
|
```
|
||||||
usage: explorationtools.py [-h] {bodycount,distancebetween,findcommander} ...
|
usage: explorationtools.py [-h]
|
||||||
|
{bodycount,distancebetween,findcommander,systemlist}
|
||||||
|
...
|
||||||
|
|
||||||
A collection of tools useful for exploration.
|
A collection of tools useful for exploration.
|
||||||
|
|
||||||
|
@ -42,7 +44,7 @@ optional arguments:
|
||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
|
|
||||||
subcommands:
|
subcommands:
|
||||||
{bodycount,distancebetween,findcommander}
|
{bodycount,distancebetween,findcommander,systemlist}
|
||||||
sub-command help
|
sub-command help
|
||||||
bodycount Returns the number of bodies in a system. Will exit
|
bodycount Returns the number of bodies in a system. Will exit
|
||||||
with code 1 on server error and code 2 if the system
|
with code 1 on server error and code 2 if the system
|
||||||
|
@ -53,6 +55,8 @@ subcommands:
|
||||||
findcommander Attempts to find a CMDR’s last known position. Will
|
findcommander Attempts to find a CMDR’s last known position. Will
|
||||||
exit with code 1 on server error and code 2 if the
|
exit with code 1 on server error and code 2 if the
|
||||||
CMDR could not be found on EDSM.
|
CMDR could not be found on EDSM.
|
||||||
|
systemlist Pulls all system names starting with the given string
|
||||||
|
from EDSM
|
||||||
```
|
```
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -91,6 +95,16 @@ optional arguments:
|
||||||
--url output the commander’s profile URL
|
--url output the commander’s profile URL
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
usage: explorationtools.py systemlist [-h] partialsystem
|
||||||
|
|
||||||
|
positional arguments:
|
||||||
|
partialsystem the partial system name to query against
|
||||||
|
|
||||||
|
optional arguments:
|
||||||
|
-h, --help show this help message and exit
|
||||||
|
```
|
||||||
|
|
||||||
## Need Help / Want to Contribute? ##
|
## Need Help / Want to Contribute? ##
|
||||||
|
|
||||||
Just [file an issue](https://github.com/alterNERDtive/elite-scripts/issues/new)
|
Just [file an issue](https://github.com/alterNERDtive/elite-scripts/issues/new)
|
||||||
|
|
|
@ -29,6 +29,15 @@ def getCommanderProfileUrl(name, apikey):
|
||||||
def getCommanderSystem(name, apikey):
|
def getCommanderSystem(name, apikey):
|
||||||
return Commander(name, apikey).currentSystem
|
return Commander(name, apikey).currentSystem
|
||||||
|
|
||||||
|
def getSystemList(name):
|
||||||
|
ret = ""
|
||||||
|
|
||||||
|
systems = System.getSystems(name)
|
||||||
|
for system in systems:
|
||||||
|
ret += "{}\n".format(system.name)
|
||||||
|
|
||||||
|
return ret[:-1]
|
||||||
|
|
||||||
# ===========================================================================
|
# ===========================================================================
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="A collection of tools useful for "
|
parser = argparse.ArgumentParser(description="A collection of tools useful for "
|
||||||
|
@ -61,6 +70,11 @@ parser_find.add_argument("name", help="the commander in question")
|
||||||
parser_find.add_argument("apikey", default="", nargs="?",
|
parser_find.add_argument("apikey", default="", nargs="?",
|
||||||
help="the commander’s EDSM API key. Can be empty for public profiles.")
|
help="the commander’s EDSM API key. Can be empty for public profiles.")
|
||||||
|
|
||||||
|
parser_bodycount = subparsers.add_parser("systemlist",
|
||||||
|
help="Pulls all system names starting with the given string from EDSM")
|
||||||
|
parser_bodycount.add_argument("partialsystem", nargs=1,
|
||||||
|
help="the partial system name to query against")
|
||||||
|
|
||||||
argcomplete.autocomplete(parser)
|
argcomplete.autocomplete(parser)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -78,6 +92,8 @@ try:
|
||||||
out = getCommanderProfileUrl(args.name, args.apikey)
|
out = getCommanderProfileUrl(args.name, args.apikey)
|
||||||
else:
|
else:
|
||||||
out = getCommanderSystem(args.name, args.apikey)
|
out = getCommanderSystem(args.name, args.apikey)
|
||||||
|
elif args.subCommand == "systemlist":
|
||||||
|
out = getSystemList(args.partialsystem)
|
||||||
except ServerError as e:
|
except ServerError as e:
|
||||||
print(e)
|
print(e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
|
@ -47,6 +47,12 @@ EOF
|
||||||
cat >> README.md << EOF
|
cat >> README.md << EOF
|
||||||
\`\`\`
|
\`\`\`
|
||||||
|
|
||||||
|
\`\`\`
|
||||||
|
EOF
|
||||||
|
./explorationtools.py systemlist -h >> README.md
|
||||||
|
cat >> README.md << EOF
|
||||||
|
\`\`\`
|
||||||
|
|
||||||
## Need Help / Want to Contribute? ##
|
## Need Help / Want to Contribute? ##
|
||||||
|
|
||||||
Just [file an issue](https://github.com/alterNERDtive/elite-scripts/issues/new)
|
Just [file an issue](https://github.com/alterNERDtive/elite-scripts/issues/new)
|
||||||
|
|
2
pyEDSM
2
pyEDSM
|
@ -1 +1 @@
|
||||||
Subproject commit 318ad170111f95395a4cf9c16222f180ab4c1c0a
|
Subproject commit b476c34de50e6a76f93a522140acbf3536f18728
|
Loading…
Reference in a new issue