-
-
Notifications
You must be signed in to change notification settings - Fork 37
feat: Headless CLI use #649
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
Open
dhnaranjo
wants to merge
12
commits into
nix-community:main
Choose a base branch
from
dhnaranjo:headless-cli
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add --headless flag that accepts defaults for all prompts except URL, enabling automation and CI/CD integration. When --headless is enabled: - URL must be provided via --url (required) - Package name must be auto-detected or provided - Build type uses first auto-detected option - Output path defaults to current directory - Submodule fetching skipped by default - File overwrite protection (errors instead of prompting) Future commits will add flags to customize behavior in headless mode.
Introduce a macro to handle the repetitive pattern of: - Use flag value if provided - Use default value in headless mode - Prompt user in interactive mode Apply the macro to URL handling, replacing the early validation with a more idiomatic error in the default branch. This pattern will be used for all subsequent flag additions.
Add --rev flag to specify the git revision, tag, or commit hash from the command line, making version selection non-interactive. Uses the flag_or_prompt macro to integrate with headless mode, falling back to the default revision in headless mode when not specified.
Add new --pname/-p CLI flag that allows users to specify the package name directly. Refactor pname handling to use flag_or_prompt! macro for consistent behavior between headless and interactive modes.
Add --build flag to specify the build type from the command line, making build system selection non-interactive. Accepts short flag values: go-mod (buildGoModule) python-app (buildPythonApplication) python-pkg (buildPythonPackage) rust-pkg (buildRustPackage) drv (stdenv.mkDerivation) Validates against detected options and provides clear error messages listing available choices. In headless mode without --build, defaults to the first auto-detected build type.
Add --version/-v flag to specify the package version from the command line, allowing users to override auto-detected versions. Uses the flag_or_prompt macro to integrate with headless mode. In headless mode without --version, uses the auto-detected version directly without confirmation.
Add --fetch-submodules flag to explicitly control whether git submodules should be fetched. Behavior: - With --fetch-submodules: Always fetch submodules - Without flag in headless mode: Skip submodules (default) - Without flag in interactive mode: Prompt user
Add --force/-f flag to control file overwrite behavior in headless mode. Behavior: - With --force: Silently overwrite existing files - Without --force in headless mode: Error with helpful message - In interactive mode: Prompt user (--force has no effect) This provides safe defaults while allowing automation when needed.
Replace large pattern matching blocks with centralized methods in BuildType: - Add cli_flag() to get flag name for each build type - Add from_cli_flag() to parse flag string into BuildType - Reduces ~60 lines of repetitive matching to ~15 lines - Improves maintainability for adding new build types - Error messages now automatically filter unavailable options
adc6bc4 to
d38f30f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add headless mode to nix-init, enabling fully non-interactive package
initialization through CLI flags.
--headlessrequires--url, all other flags use the default value logic from the interactive flow.I'mma be real with you, I am not a Rust guy and I did have heavy LLM involvement in this thing, but I did sit here and write it, no vibe nonsense. I stand by it, but it might not be super idiomatic Rust.
fixes #648
• --headless - Enable non-interactive mode (requires --url)
• --rev - Specify git revision, tag, or commit hash
• --version-name - Specify package version
• --pname - Specify package name
• --build - Specify build type (go-mod, python-app, python-pkg, rust-pkg, drv)
• --fetch-submodules - Control submodule fetching (defaults to false in headless mode)
• --force - Allow overwriting existing output files in headless mode