Skip to content

Commit

Permalink
Add `--all' option to open all yaml files
Browse files Browse the repository at this point in the history
Adds `--all` to open all yaml files in workspace config directory.
  • Loading branch information
dapomeroy committed Dec 19, 2024
1 parent 59f8cc2 commit 3809e5a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
10 changes: 10 additions & 0 deletions lib/ramble/ramble/cmd/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,14 @@ def workspace_edit_setup_parser(subparser):
required=False,
)

subparser.add_argument(
"--all",
dest="all_files",
action="store_true",
help="Open all yaml and template files in workspace config directory",
required=False,
)

subparser.add_argument(
"-p", "--print-file", action="store_true", help="print the file name that would be edited"
)
Expand Down Expand Up @@ -935,6 +943,8 @@ def workspace_edit(args):
elif args.license_only:
licenses_file = [ramble.workspace.licenses_file(ramble_ws)]
edit_files = licenses_file
elif args.all_files:
edit_files = ramble.workspace.all_config_files(ramble_ws) + template_files

if args.print_file:
for f in edit_files:
Expand Down
2 changes: 2 additions & 0 deletions lib/ramble/ramble/workspace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
modifiers_file_name,
software_file,
software_file_name,
all_config_files,
licenses_file,
licenses_file_name,
metadata_file_name,
Expand Down Expand Up @@ -84,6 +85,7 @@
"modifiers_file_name",
"software_file",
"software_file_name",
"all_config_files",
"licenses_file",
"licenses_file_name",
"metadata_file_name",
Expand Down
12 changes: 12 additions & 0 deletions lib/ramble/ramble/workspace/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,18 @@ def licenses_file(path):
return get_yaml_filepath(path, licenses_file_name)


def all_config_files(path):
"""Returns path to all yaml files in workspace config directory"""
config_files = []

config_path = os.path.join(path, workspace_config_path)
for f in os.listdir(config_path):
if f.endswith(".yaml"):
config_files.append(os.path.join(config_path, f))

return config_files


def template_path(ws_path, requested_template_name):
"""Returns the path to a workspace's template file"""
config_path = os.path.join(ws_path, workspace_config_path)
Expand Down
2 changes: 1 addition & 1 deletion share/ramble/ramble-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ _ramble_workspace_info() {
}

_ramble_workspace_edit() {
RAMBLE_COMPREPLY="-h --help -c --config_only -a --applications_only -m --modifiers_only -s --software_only -t --template_only -l --license_only -p --print-file"
RAMBLE_COMPREPLY="-h --help -c --config_only -a --applications_only -m --modifiers_only -s --software_only -t --template_only -l --license_only --all -p --print-file"
}

_ramble_workspace_mirror() {
Expand Down

0 comments on commit 3809e5a

Please sign in to comment.