Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pmbootstrap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
postmarketOS
pmbootstrap
Commits
1605e9e9
Commit
1605e9e9
authored
6 years ago
by
Grant Miller
Browse files
Options
Downloads
Patches
Plain Diff
Add command to install completion script
parent
9d1eb5a1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pmb/helpers/frontend.py
+28
-0
28 additions, 0 deletions
pmb/helpers/frontend.py
pmb/parse/arguments.py
+10
-0
10 additions, 0 deletions
pmb/parse/arguments.py
setup.py
+1
-1
1 addition, 1 deletion
setup.py
with
39 additions
and
1 deletion
pmb/helpers/frontend.py
+
28
−
0
View file @
1605e9e9
...
...
@@ -363,3 +363,31 @@ def bootimg_analyze(args):
for
line
in
pmb
.
aportgen
.
device
.
generate_deviceinfo_fastboot_content
(
args
,
bootimg
).
split
(
"
\n
"
):
tmp_output
+=
"
\n
"
+
line
.
lstrip
()
logging
.
info
(
tmp_output
)
def
register_bash_completion
(
args
):
try
:
import
argcomplete
except
ImportError
:
raise
RuntimeError
(
"
Could not find argcomplete! You can install it
"
"
with
'
pip3 install argcomplete
'"
)
dest
=
os
.
path
.
abspath
(
os
.
path
.
expanduser
(
args
.
dest
))
command
=
os
.
path
.
basename
(
sys
.
argv
[
0
])
dest_file
=
os
.
path
.
join
(
dest
,
command
)
if
args
.
uninstall
:
logging
.
info
(
"
Removing file {}
"
.
format
(
dest_file
))
os
.
remove
(
dest_file
)
try
:
os
.
removedirs
(
dest
)
except
OSError
:
pass
else
:
if
"
shellcode
"
not
in
dir
(
argcomplete
):
raise
RuntimeError
(
"
Argcomplete must be >=1.9.4. You can update
"
"
with
'
pip3 install --upgrade argcomplete
'"
)
logging
.
info
(
"
Writing to {}
"
.
format
(
dest_file
))
os
.
makedirs
(
dest
,
mode
=
0o755
,
exist_ok
=
True
)
with
open
(
dest_file
,
"
w
"
)
as
f
:
f
.
write
(
argcomplete
.
shellcode
(
command
))
logging
.
info
(
"
Success! Please close and re-open your terminal to
"
"
enable bash completion
"
)
This diff is collapsed.
Click to expand it.
pmb/parse/arguments.py
+
10
−
0
View file @
1605e9e9
...
...
@@ -478,6 +478,16 @@ def arguments():
help
=
"
force even if the file seems to be
"
"
invalid
"
)
# Action: register_bash_completion
completion
=
sub
.
add_parser
(
"
register_bash_completion
"
,
help
=
"
install bash completion script
"
)
completion_default_dir
=
"
~/.local/share/bash-completion/completions/
"
completion
.
add_argument
(
"
--dest
"
,
default
=
completion_default_dir
,
help
=
"
destination directory, default: {}
"
.
format
(
completion_default_dir
))
completion
.
add_argument
(
"
--uninstall
"
,
action
=
"
store_true
"
,
help
=
"
remove bash completion script
"
)
if
argcomplete
:
argcomplete
.
autocomplete
(
parser
,
always_complete_options
=
"
long
"
)
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
1
View file @
1605e9e9
...
...
@@ -59,7 +59,7 @@ setup(
tests_require
=
[
'
pytest
'
],
cmdclass
=
{
'
test
'
:
PyTest
},
extras_require
=
{
'
argcomplete
'
:
[
"
argcomplete
"
],
'
argcomplete
'
:
[
"
argcomplete
>=1.9.4
"
],
},
entry_points
=
{
'
console_scripts
'
:
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment