Skip to content

feat(completion): Add path completion#150

Merged
water-sucks merged 1 commit intonix-community:mainfrom
Sporif:completion-path-feature
Jan 22, 2026
Merged

feat(completion): Add path completion#150
water-sucks merged 1 commit intonix-community:mainfrom
Sporif:completion-path-feature

Conversation

@Sporif
Copy link
Copy Markdown
Collaborator

@Sporif Sporif commented Jan 19, 2026

This adds:

  • path completion to the first positional parameter of apply, install and repl
    • directory completion in flake builds ([FLAKE-REF])
    • file completion in legacy builds ([FILE])
  • directory completion to:
    • enter:
      • --root, --system
    • install:
      • --channel, --root, --system
    • init:
      • --dir, --root
    • option:
      • --flake
  • file completion to:
    • option:
      • --file

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jan 19, 2026

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator

@water-sucks water-sucks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

carapace supports usage of cobra completions.

IMO it is probably far simpler to specify the ValidArgsFunction attribute for each *cobra.Command instance that requires it, and return completion directives there that carapace then picks up, like so:

ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
	if build.Flake() {
		return nil, cobra.ShellCompDirectiveFilterDirs
	} else {
		return nil, cobra.ShellCompDirectiveDefault
	}
},

you can adapt as needed for other positional arguments.

@Sporif Sporif force-pushed the completion-path-feature branch from fe1da2b to cdd9d84 Compare January 22, 2026 11:40
@Sporif
Copy link
Copy Markdown
Collaborator Author

Sporif commented Jan 22, 2026

So something like this? I also added nix file extension filtering for the legacy [FILE] arg and --file flag.

Copy link
Copy Markdown
Collaborator

@water-sucks water-sucks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good! Just one small change :}

@Sporif Sporif force-pushed the completion-path-feature branch from cdd9d84 to b3e1ea3 Compare January 22, 2026 22:44
Copy link
Copy Markdown
Collaborator

@water-sucks water-sucks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the changes!

@water-sucks water-sucks merged commit a5d6153 into nix-community:main Jan 22, 2026
2 checks passed
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