-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Misc: Add CLI interface to create-change-note.py
#21154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This may be useful when working in "the other place", where the VSCode task may not be easily accessible. (Also, some people may just prefer to use a CLI interface.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds an interactive CLI mode to the create-change-note.py script, allowing users to run it without command-line arguments and be prompted for inputs interactively. This provides an alternative to the existing argument-based interface, which can be useful in environments where VSCode tasks are not easily accessible.
Changes:
- Added interactive mode with user-friendly prompts and subsequence matching for option selection
- Maintained backward compatibility with the existing command-line argument interface
- Added constants for valid languages, subdirectories, and change categories
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| language = sys.argv[1] | ||
| subdir = sys.argv[2] | ||
| change_note_name = sys.argv[3] | ||
| change_category = sys.argv[4] |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When running in argument mode (len(sys.argv) == 5), there is no validation of the provided arguments. The language, subdir, and change_category values are not verified against the valid options defined in LANGUAGES, SUBDIRS, and CATEGORIES_* constants. Invalid values would only fail later when trying to create the output directory path. Consider adding validation to provide clearer error messages when invalid arguments are provided.
| language = sys.argv[1] | |
| subdir = sys.argv[2] | |
| change_note_name = sys.argv[3] | |
| change_category = sys.argv[4] | |
| language, subdir, change_note_name, change_category = sys.argv[1:5] | |
| # Validate language | |
| if language not in LANGUAGES: | |
| print(f"Invalid language: {language}") | |
| print(f"Valid languages: {', '.join(LANGUAGES)}") | |
| sys.exit(1) | |
| # Validate subdir | |
| if subdir not in SUBDIRS: | |
| print(f"Invalid subdir: {subdir}") | |
| print(f"Valid subdirs: {', '.join(SUBDIRS.keys())}") | |
| sys.exit(1) | |
| # Validate category based on subdir (query vs library) | |
| if subdir == "src": | |
| valid_categories = CATEGORIES_QUERY | |
| else: | |
| valid_categories = CATEGORIES_LIBRARY | |
| if change_category not in valid_categories: | |
| print(f"Invalid category: {change_category}") | |
| print(f"Valid categories for {subdir}: {', '.join(valid_categories)}") | |
| sys.exit(1) | |
| # Basic validation for change note name (match interactive behavior) | |
| if not change_note_name.strip(): | |
| print("Change note name must be non-empty.") | |
| sys.exit(1) |
| language = pick_option("Select language:", LANGUAGES) | ||
| subdir = pick_option("Change type:", list(SUBDIRS.keys())) | ||
|
|
||
| change_note_name = prompt_string("Short name (kebab-case)") |
Copilot
AI
Jan 12, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The prompt_string function prompts for a "Short name (kebab-case)" but does not validate that the input is actually in kebab-case format. This could lead to incorrectly formatted filenames. Consider adding validation to ensure the input matches the expected kebab-case pattern (lowercase letters, numbers, and hyphens only, not starting or ending with a hyphen).
This may be useful when working in "the other place", where the VSCode task may not be easily accessible. (Also, some people may just prefer to use a CLI interface.)