mirror of
https://gitlab.freedesktop.org/upower/power-profiles-daemon.git
synced 2026-05-08 17:09:35 +02:00
powerprofilectl: Generate manpage using argparse-manpage
Add an option to toggle this feature so that it can be either required or not
This commit is contained in:
parent
7cd764c075
commit
7858623142
4 changed files with 43 additions and 2 deletions
|
|
@ -56,6 +56,8 @@ if get_option('pylint')
|
|||
endif
|
||||
xmllint = find_program('xmllint', required: false)
|
||||
|
||||
argparse_manpage = find_program('argparse-manpage', required: get_option('manpage'))
|
||||
|
||||
bus_names = {
|
||||
'org.freedesktop.UPower.PowerProfiles': '/org/freedesktop/UPower/PowerProfiles',
|
||||
'net.hadess.PowerProfiles': '/net/hadess/PowerProfiles',
|
||||
|
|
|
|||
|
|
@ -14,3 +14,7 @@ option('tests',
|
|||
description: 'Whether to run tests',
|
||||
type: 'boolean',
|
||||
value: true)
|
||||
option('manpage',
|
||||
description: 'gemerate powerprofilesctl man page',
|
||||
type: 'feature',
|
||||
value: 'auto')
|
||||
|
|
|
|||
|
|
@ -115,3 +115,34 @@ if get_option('pylint')
|
|||
env: nomalloc,
|
||||
)
|
||||
endif
|
||||
|
||||
if argparse_manpage.found()
|
||||
argparse_features = run_command(argparse_manpage, '--help',
|
||||
check: true).stdout().strip()
|
||||
|
||||
install_man(configure_file(
|
||||
command: [
|
||||
argparse_manpage,
|
||||
'--pyfile', powerprofilesctl,
|
||||
'--function', 'get_parser',
|
||||
argparse_features.contains('--author') ?
|
||||
['--author', 'Bastien Nocera', '--author', 'Mario Limonciello'] : [],
|
||||
argparse_features.contains('--author-email') ?
|
||||
['--author-email', 'hadess@hadess.net', '--author-email', 'mario.limonciello@amd.com'] : [],
|
||||
argparse_features.contains('--project-name') ?
|
||||
['--project-name', meson.project_name()] : [],
|
||||
argparse_features.contains('--version') ?
|
||||
['--version', meson.project_version()] : [],
|
||||
argparse_features.contains('--url') ?
|
||||
['--url', 'https://gitlab.freedesktop.org/upower/power-profiles-daemon'] : [],
|
||||
argparse_features.contains('--description') ?
|
||||
['--manual-title', 'Power Profiles Daemon Control Program'] : [],
|
||||
argparse_features.contains('--description') ?
|
||||
['--description', 'Command line utility to control Power Profiles Daemon'] : [],
|
||||
argparse_features.contains('--format') ?
|
||||
['--format', 'single-commands-section'] : [],
|
||||
],
|
||||
capture: true,
|
||||
output: 'powerprofilesctl.1',
|
||||
))
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ def _launch(args):
|
|||
return ret
|
||||
|
||||
|
||||
def main():
|
||||
def get_parser():
|
||||
parser = argparse.ArgumentParser(
|
||||
epilog="Use “powerprofilesctl COMMAND --help” to get detailed help for individual commands",
|
||||
)
|
||||
|
|
@ -190,7 +190,11 @@ def main():
|
|||
)
|
||||
parser_version.set_defaults(func=_version)
|
||||
|
||||
args = parser.parse_args()
|
||||
return parser
|
||||
|
||||
|
||||
def main():
|
||||
args = get_parser().parse_args()
|
||||
# default behavior is to run list if no command is given
|
||||
if not args.command:
|
||||
args.func = _list
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue