mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
Implement proper fdroid --help
This commit is contained in:
parent
a1d85e32f1
commit
687057a473
1 changed files with 31 additions and 27 deletions
58
fdroid
58
fdroid
|
@ -21,27 +21,30 @@
|
||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
commands = [
|
commands = {
|
||||||
"build",
|
"build": "Build a package from source",
|
||||||
"init",
|
"init": "Quickly start a new repository",
|
||||||
"install",
|
"publish": "Sign and place packages in the repo",
|
||||||
"update",
|
"update": "Update repo information for new packages",
|
||||||
"publish",
|
"verify": "Verify the integrity of downloaded packages",
|
||||||
"verify",
|
"checkupdates": "Check for updates to applications",
|
||||||
"checkupdates",
|
"import": "Add a new application from its source code",
|
||||||
"import",
|
"install": "Install built packages on devices",
|
||||||
"readmeta",
|
"readmeta": "Read all the metadata files and exit",
|
||||||
"rewritemeta",
|
"rewritemeta": "Rewrite all the metadata files",
|
||||||
"lint",
|
"lint": "Warn about possible metadata errors",
|
||||||
"scanner",
|
"scanner": "Scan the source code of a package",
|
||||||
"stats",
|
"stats": "Update the stats of the repo",
|
||||||
"server"]
|
"server": "Interact with the repo HTTP server",
|
||||||
|
}
|
||||||
|
|
||||||
def print_help():
|
def print_help():
|
||||||
|
print "usage: fdroid [-h|--help] <command> [<args>]"
|
||||||
|
print
|
||||||
print "Valid commands are:"
|
print "Valid commands are:"
|
||||||
for command in commands:
|
for cmd,summary in commands.items():
|
||||||
print " " + command
|
print " " + cmd + ' '*(15-len(cmd)) + summary
|
||||||
print "Use '%s <command> --help' for more info about that command."%sys.argv[0]
|
print
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
||||||
|
@ -50,20 +53,21 @@ def main():
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
command = sys.argv[1]
|
command = sys.argv[1]
|
||||||
if not command in commands:
|
if command not in commands:
|
||||||
if command not in ('-h', '--help'):
|
if command in ('-h', '--help'):
|
||||||
print "Command '" + command + "' not recognised.\n"
|
print_help()
|
||||||
print_help()
|
sys.exit(0)
|
||||||
sys.exit(1)
|
else:
|
||||||
|
logging.error("Command '" + command + "' not recognised.\n")
|
||||||
|
print_help()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
verbose = any(s in sys.argv for s in ['-v', '--verbose'])
|
verbose = any(s in sys.argv for s in ['-v', '--verbose'])
|
||||||
|
|
||||||
if verbose:
|
if verbose:
|
||||||
logging.basicConfig(format='%(levelname)s: %(message)s',
|
logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG)
|
||||||
level=logging.DEBUG)
|
|
||||||
else:
|
else:
|
||||||
logging.basicConfig(format='%(message)s',
|
logging.basicConfig(format='%(message)s', level=logging.INFO)
|
||||||
level=logging.INFO)
|
|
||||||
|
|
||||||
# Trick optparse into displaying the right usage when --help is used.
|
# Trick optparse into displaying the right usage when --help is used.
|
||||||
sys.argv[0] += ' ' + command
|
sys.argv[0] += ' ' + command
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue