Skip to content

Add --dir option to devopsos init command#13

Merged
chefgs merged 4 commits intomainfrom
copilot/add-setup-instructions
Mar 7, 2026
Merged

Add --dir option to devopsos init command#13
chefgs merged 4 commits intomainfrom
copilot/add-setup-instructions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

devopsos init hardcoded .devcontainer output to the current working directory with no way to redirect it.

Changes

cli/devopsos.py

  • Added --dir option (Python param directory, default .) to init() — fully backward-compatible
  • Output path changed from Path(".devcontainer")Path(directory) / ".devcontainer"
  • mkdir upgraded to parents=True to support nested target paths

cli/test_cli.py

  • Added _strip_ansi() helper to handle ANSI escape codes that typer/rich emits in help text, making --option string assertions reliable
  • test_init_help_shows_dir_option — verifies --dir appears in init --help
  • test_init_dir_option_creates_devcontainer_in_specified_dir — functional test using CliRunner with patched InquirerPy that confirms .devcontainer/devcontainer.env.json lands in the specified directory

Usage

python -m cli.devopsos init                    # unchanged — writes to ./.devcontainer
python -m cli.devopsos init --dir my-project   # writes to my-project/.devcontainer
python -m cli.devopsos init --dir /some/path   # absolute paths supported

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits March 7, 2026 08:00
…psos CLI

When invoked as `python -m cli.devopsos scaffold <target>`, the scaffold
module's argparse would read sys.argv and see 'scaffold <target>' as
unrecognized arguments. Fix by saving and restoring sys.argv around each
scaffold main() call in devopsos.py so argparse falls back to env-var/
default values. Add regression tests for gha, gitlab and argocd.

Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add setup instructions for running CLI commands Fix python -m cli.devopsos scaffold <target> failing with "unrecognized arguments" Mar 7, 2026
Lets users specify where the .devcontainer folder is scaffolded
instead of always writing to the current working directory.

  python -m cli.devopsos init --dir my-project

Renames the parameter from `dir` to `directory` to avoid shadowing
the Python built-in. Adds _strip_ansi() test helper and two new tests:
one for --help visibility, one functional test verifying the directory
is used.

Co-authored-by: chefgs <7605658+chefgs@users.noreply.github.com>
Copilot AI changed the title Fix python -m cli.devopsos scaffold <target> failing with "unrecognized arguments" Add --dir option to devopsos init command Mar 7, 2026
@chefgs chefgs marked this pull request as ready for review March 7, 2026 10:04
@chefgs chefgs merged commit b5b8417 into main Mar 7, 2026
4 checks passed
@chefgs chefgs deleted the copilot/add-setup-instructions branch March 7, 2026 10:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants