Skip to content

Commit 750b0b1

Browse files
committed
gopinath-langote#96 Preliminary command completion
1 parent da89642 commit 750b0b1

File tree

6 files changed

+31
-0
lines changed

6 files changed

+31
-0
lines changed

onebuild/1build_completion.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/bash
2+
_1build_completions()
3+
{
4+
COMPREPLY=($(compgen -W "$(1build -lr | sed 's/\\t//')" -- "${COMP_WORDS[COMP_CWORD]}"))
5+
}
6+
7+
complete -F _1build_completions 1build

onebuild/action_to_command_lookup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from onebuild.help_command import HelpCommand
33
from onebuild.init_command import InitCommand
44
from onebuild.list_command import ListCommand
5+
from onebuild.list_raw_command import ListRawCommand
56
from onebuild.perform_command import PerformCommand
67
from onebuild.version_command import VersionCommand
78

@@ -13,6 +14,7 @@ def __init__(self):
1314
PredefinedActions.HELP: HelpCommand(),
1415
PredefinedActions.INIT: InitCommand(),
1516
PredefinedActions.LIST: ListCommand(),
17+
PredefinedActions.LIST_RAW: ListRawCommand(),
1618
PredefinedActions.VERSION: VersionCommand(),
1719
PredefinedActions.PERFORM: PerformCommand()
1820
})

onebuild/input_parser.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def argument_parser():
2424
default=False,
2525
help="Show all available commands - from `1build.yaml` file"
2626
)
27+
parser.add_argument(
28+
'-lr', '--listraw',
29+
action='store_true',
30+
default=False,
31+
help="Show all available command names - from `1build.yaml` file"
32+
)
2733
parser.add_argument(
2834
'-v', '--version',
2935
dest='version',
@@ -50,6 +56,8 @@ def command_to_run(arg_parser, arguments):
5056
return PredefinedActions.INIT
5157
if args.list:
5258
return PredefinedActions.LIST
59+
if args.listraw:
60+
return PredefinedActions.LIST_RAW
5361
if len(args.command) == 0:
5462
return PredefinedActions.HELP
5563

onebuild/list_raw_command.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from onebuild.command import Command
2+
from onebuild.config_parser import parse_project_config
3+
from onebuild.utils import config_string
4+
5+
6+
class ListRawCommand(Command):
7+
8+
def execute(self, arg_parser, arguments, build_file_name, command_name):
9+
project = parse_project_config(build_file_name)
10+
print(project.get_command_names())

onebuild/predefined_actions.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ class PredefinedActions:
22
VERSION = "ONEBUILD_VERSION"
33
HELP = "ONEBUILD_HELP"
44
LIST = "ONEBUILD_LIST"
5+
LIST_RAW = "ONEBUILD_LIST_RAW"
56
INIT = "ONEBUILD_INIT"
67
PERFORM = "ONEBUILD_PERFROM"

onebuild/project.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ def available_commands(self):
4242
def __str__(self):
4343
return "project: " + self.name + "\ncommands:\n" + \
4444
self.available_commands()
45+
46+
def get_command_names(self):
47+
return "\n".join(map(lambda command: command.name, self.commands))

0 commit comments

Comments
 (0)