Skip to content

Commit

Permalink
chore: changes space separated flag inputs to comma separated
Browse files Browse the repository at this point in the history
Signed-off-by: Jennifer Power <barnabei.jennifer@gmail.com>
  • Loading branch information
jpower432 committed Jul 5, 2023
1 parent ddd0ade commit ad832fe
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ inputs:
required: false
default: false
skip_items:
description: "Space-separated list of content by Trestle name to skip during task execution. For example `profile_x profile_y`."
description: "Comma-separated list of content by Trestle name to skip during task execution. For example `profile_x,profile_y`."
required: false
default: ""
ssp_index_path:
Expand All @@ -38,7 +38,7 @@ inputs:
required: false
default: ${{ github.ref_name }}
file_pattern:
description: File pattern used for `git add`. For example `component-definitions/*`. Defaults to (`.`)
description: Comma seperated file pattern list used for `git add`. For example `component-definitions/*,*json`. Defaults to (`.`)
required: false
default: '.'
repository:
Expand Down
2 changes: 1 addition & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ command="python3.8 -m trestlebot \
--ssp-index-path=\"${INPUT_SSP_INDEX_PATH}\" \
--commit-message=\"${INPUT_COMMIT_MESSAGE}\" \
--branch=\"${INPUT_BRANCH}\" \
--file-pattern=\"${INPUT_FILE_PATTERN}\" \
--file-patterns=\"${INPUT_FILE_PATTERN}\" \
--committer-name=\"${INPUT_COMMIT_USER_NAME}\" \
--committer-email=\"${INPUT_COMMIT_USER_EMAIL}\" \
--author-name=\"${INPUT_COMMIT_AUTHOR_NAME}\" \
Expand Down
3 changes: 2 additions & 1 deletion tests/trestlebot/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import pytest

from trestlebot.cli import _parse_cli_arguments
from trestlebot.cli import run as cli_main


Expand All @@ -34,7 +35,7 @@ def valid_args_dict() -> dict:
"committer-name": "test",
"committer-email": "test@email.com",
"working-dir": "tmp",
"file-pattern": ".",
"file-patterns": ".",
}


Expand Down
19 changes: 13 additions & 6 deletions trestlebot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,17 @@ def _parse_cli_arguments() -> argparse.Namespace:
help="OSCAL model type to run tasks on. Values can be catalog, profile, compdef, or ssp",
)
parser.add_argument(
"--file-pattern",
"--file-patterns",
required=True,
type=str,
help="File pattern to be used with `git add` in repository updates",
help="Comma-separated list of file patterns to be used with `git add` in repository updates",
)
parser.add_argument(
"--skip-items",
nargs="+",
type=str,
required=False,
default=[],
help="List of items of the chosen model type to skip when running tasks",
default="",
help="Comma-separated list of items of the chosen model type to skip when running tasks",
)
parser.add_argument(
"--skip-assemble",
Expand Down Expand Up @@ -180,6 +179,7 @@ def run() -> None:
args.oscal_model,
args.markdown_path,
args.ssp_index_path,
comma_sep_to_list(args.skip_items),
)
pre_tasks.append(assemble_task)
else:
Expand All @@ -191,6 +191,7 @@ def run() -> None:
args.oscal_model,
args.markdown_path,
args.ssp_index_path,
comma_sep_to_list(args.skip_items),
)
pre_tasks.append(regenerate_task)
else:
Expand All @@ -210,7 +211,7 @@ def run() -> None:
author_name=args.author_name,
author_email=args.author_email,
pre_tasks=pre_tasks,
patterns=[args.file_pattern],
patterns=comma_sep_to_list(args.file_patterns),
check_only=args.check_only,
)

Expand All @@ -222,3 +223,9 @@ def run() -> None:
exit_code = handle_exception(e)

sys.exit(exit_code)


def comma_sep_to_list(string: str) -> List[str]:
"""Convert comma-sep string to list of strings and strip."""
string = string.strip() if string else ""
return list(map(str.strip, string.split(","))) if string else []

0 comments on commit ad832fe

Please sign in to comment.