mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-26 03:31:36 +01:00
getvar: move docs to --help
This commit is contained in:
14
README.adoc
14
README.adoc
@@ -9488,20 +9488,6 @@ These appear when you do `./some-script -h`.
|
||||
|
||||
We have to keep them as separate files from the README for that to be possible.
|
||||
|
||||
==== getvar
|
||||
|
||||
The link:getvar[] helper script prints the value of a variable from the link:common[] file.
|
||||
|
||||
For example, to get the Buildroot output directory for an ARM build, you can use:
|
||||
|
||||
....
|
||||
./getvar -a arm buildroot_out_dir
|
||||
....
|
||||
|
||||
This script exists mostly to factor out instructions given on the README which users are expected to copy paste into the terminal.
|
||||
|
||||
Otherwise, it becomes very difficult to keep everything working across path refactors, since README snippets cannot be tested automatically.
|
||||
|
||||
==== build
|
||||
|
||||
....
|
||||
|
||||
19
getvar
19
getvar
@@ -1,8 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
import common
|
||||
parser = common.get_argparse(
|
||||
argparse_args={'description':'https://github.com/cirosantilli/linux-kernel-module-cheat#getvar'}
|
||||
)
|
||||
parser = common.get_argparse(argparse_args={
|
||||
'description':'''Print the value of a common.py variable.
|
||||
|
||||
This is useful to:
|
||||
|
||||
* give dry commands on the README that don't change when we refactor directory structure
|
||||
* create simple bash scripts that call use common.py variables
|
||||
|
||||
For example, to get the Buildroot output directory for an ARM build, use:
|
||||
|
||||
....
|
||||
./%(prog)s -a arm buildroot_out_dir
|
||||
....
|
||||
|
||||
'''
|
||||
})
|
||||
parser.add_argument('variable')
|
||||
args = common.setup(parser)
|
||||
print(getattr(common, args.variable))
|
||||
|
||||
Reference in New Issue
Block a user