🐇 So, what’s next?
🐲 We can work on completions or the GUI.
🐢 Completions are similar to the Homebrew work. It’s in another ecosystem and feels boring.
🐲 We can try to make it in Rust: “Writing shell completions in Rust.”
🐢 There are two solutions: One is clap_complete (https://docs.rs/clap_complete/latest/clap_complete/) and the other is shell_completion (https://github.com/JoshMcguigan/shell_completion). The latter is very new but may be what we need: writing completions only with Rust.
🐲 The shell_completion crate is very bare-bones. It doesn’t have anything, actually. https://github.com/JoshMcguigan/shell_completion/issues/1
🐇 The feature that we need is dynamic completion. We’ll write something similar to ArgValueCompleter for this.
🦊 I think we can just start a new branch.
🐲 We have a branch for Homebrew; should we merge it?
🐢 I think, yes, we can merge it. We’ll fix it if it breaks. It’s a separate workflow file anyway.
🦊 Created the PR.
ghpl
264 add brew tap add-brew-tap OPEN 2025-01-03T05:14:45Z
🐢 Merged it.
🐇 Now let’s create a new branch and add clap-complete to Cargo.toml.
🐲 There are some packages that we need to take a look at. thiserror now has v2.
🐢 Upgraded packages and compiled. It works.
🐲 Let’s update the version.
🐢 Done. Now we can add clap-complete.
🦊 Added with the unstable-dynamic command. Can we build it again?
🐢 Built it. Now we can add a completions subcommand to Xvc.
🐲 Is this the right name for this?
🐢 It will output a shell script that we can source in the shell.
🐲 Okay, let’s add the subcommand now.
🐢 The example doesn’t work with the clap builder.
🐇 Let’s search for it.
🐢 I think we’re extending ourselves a bit when trying to add all dynamic features of completion at once. We can just start by adding completion to xvc-test-helper.
🐇 Yep, that’s a better idea. We can have many more examples, and it’s certainly more straightforward.
🐢 One thing I noticed when working yesterday is that using auto-save was actually preventing many of these swap errors.
🐲 It was a bit slow. Can we take a look at a few others?
🐢 https://github.com/okuuva/auto-save.nvim seems a bit more polished.
🐇 Installed it, but haven’t seen an effect yet.
🐢 We may need to restart this.
🐲 Now, we can get into the test-helper completions.
🐢 Done. Added these quickly as you thought. Now adding this to main seems much easier.
🦊 That was a nice approach. Let’s dive into adding this to main.
🐇 Should we go with a separate command or just an option?
🐲 Our commands have distinct initial letters, allowing them to be used with just those letters. Adding another top-level command for this will make c useless.
🐢 I don’t think that’s a valid concern. We can create aliases for all commands and completions shouldn’t have to have an alias. But I agree that completions should not be a top-level command. It will be run once for installation at most.
🦊 I agree. Let’s call it --completions. It will be run as xvc --completions zsh and will print out the completions.
🐢 Okay. Let’s do this.
🦊 No errors left. Let’s install this version.
🐢 We get:
error: 'xvc' requires a subcommand but one was not provided
[subcommands: file, init, pipeline, storage, root, check-ignore, aliases, help]
Usage: xvc [OPTIONS] <COMMAND>
For more information, try '--help'.
🦊 Umm, okay. I think we don’t have an option to create a command like that. Then we’ll have to print completions with a subcommand.
🐲 The above discussion is now moot. ❌
🐢 We can try to push, but probably it’s not worth it.
🐲 Let’s not lose time on this. I think we can remove the aliases command and replace it with completions, and add single-letter aliases to subcommands.
🐢 We can have an option in the completions command to print aliases. That will work.
🦊 I don’t think people will use the aliases command if we have single-letter command aliases.
🐢 You may be right. No need to try to maintain that at this time.
🐢 Good morning, and I’m fed up with these blink.cmp errors, you know.
🐇 Reinstalling blink works. It’s interesting to rely on such unreliable software.
🐢 Oh, yeah. It’s interesting. Where were we yesterday?
🐲 We decided to rename the aliases command to completions.
🐇 And waiting for rust-analyzer to complete its analysis.
🐢 Uh, yeah. I see.
🦊 The code itself is very short, actually.
if let Some(shell) = cli_opts.completions {
let mut cmd = XvcCLI::command();
generate(shell, &mut cmd, "xvc", &mut io::stdout());
return Ok(None);
}
🐲 We’ll use the output! macro instead of writing to io::stdout(), right?
🐢 Yes, we can rely on the usual output system. It will be slower to create an output thread but shouldn’t matter for outputting a shell script.
🐇 It takes a while for rust-analyzer to scan all the directories, it looks like. When I close the project, it just cannot reload it immediately.
🐢 We can use cargo clean from time to time.
🦊 rust-analyzer finished scanning; let’s try to rename AliasesCLI.
🐲 Let’s keep these here; maybe we’ll need them in our scripts:
# Standard Xvc command aliases for longer commands.
alias xls='xvc file list'
alias pvc='xvc pipeline'
alias fvc='xvc file'
alias xvcf='xvc file'
alias xvcft='xvc file track'
alias xvcfl='xvc file list'
alias xvcfs='xvc file send'
alias xvcfb='xvc file bring'
alias xvcfh='xvc file hash'
alias xvcfco='xvc file checkout'
alias xvcfr='xvc file recheck'
alias xvcp='xvc pipeline'
alias xvcpr='xvc pipeline run'
alias xvcps='xvc pipeline step'
alias xvcpsn='xvc pipeline step new'
alias xvcpsd='xvc pipeline step dependency'
alias xvcpso='xvc pipeline step output'
alias xvcpi='xvc pipeline import'
alias xvcpe='xvc pipeline export'
alias xvcpl='xvc pipeline list'
alias xvcpn='xvc pipeline new'
alias xvcpu='xvc pipeline update'
alias xvcpd='xvc pipeline dag'
alias xvcs='xvc storage'
alias xvcsn='xvc storage new'
alias xvcsl='xvc storage list'
alias xvcsr='xvc storage remove'
🦊 We can use them when adding single-letter aliases.
🐇 There is a from_env method for Shell; will we support it?
🦊 I think we can support it. It’s much easier to use if we omit the shell.
🐲 We had aliases in xvc-core, but we need to access XvcCLI from completions. The completions module must be moved to xvc.
🦊 We added the clap_complete dependency to the xvc-pipeline and xvc-file crates, but I don’t think they are necessary. Let’s remove them now.
🐢 Now only the test-helper and xvc crates have the clap_complete dependency.
🐇 Are we ready to test?
🐢 Completions are working. 🎉
🐲 Now we need to update the docs and doc tests, I believe.
🐢 There are also tests to update.
🐇 Tests are running now. In the meantime, can we take a look at the blink configuration?
🐲 When we removed xvc aliases, we also removed pvc, xls, and other aliases. Maybe we can add these to the docs.
🐢 We can put them in the xvc completions reference for now.
🐢 It takes a while for rust-analyzer to finish analyzing the codebase.
🦊 Added aliases for xvc pipeline commands. Do you think we need to repeat root-level flags in xvc-pipeline?
🐢 No need to divert attention, I believe. Also, I still think there is an easier way to do that.
🐇 Okay. Do you think we should add easier subcommands to step? Like, step new becoming xvc p s n instead of xvc p s n? (Wait, that’s the same). I mean, more concise.
🐢 I think we can extend these even to the top-level, but shouldn’t make them visible. It will pollute the help text. We can add xvc fl for file list to avoid the space, but hide these from the help text.
🐲 That’s a good idea, but it will require including sub-crate level modules at the top level. We must test it first.
🐢 Let’s finish up the current changes and release them first.
🐇 By the way, we didn’t add two-letter abbreviations to the xvc storage new subcommands. Do you think we need them?
🐢 When we think about the frequency of these commands, no, I don’t think we need them. Users won’t add a new storage every day.
🐇 By that logic, we shouldn’t need an n for xvc storage new.
🐢 Actually, yeah. Maybe we should remove even s.
🦊 storage list may be useful.
🐢 s is a very common letter, though. We can have other uses for that letter.
🐇 Updating xvc p s dependency options, but it looks like making dependency options subcommands is a better way.
🦊 We didn’t do it because currently we can supply multiple options with a single command. If we go the subcommand route, we’ll have to write all dependencies one by one. Adding multiple subcommands with clap is a bit tricky.
🐢 Umm. Yeah, I see.
🐇 Maybe we can provide a separate command to add multiple dependencies. Like, xvc p s d add 'lines=myfile.csv::10-20; file=myimage.jpg; glob=dir/image-10*'
🐲 That looks like the start of a language. We need a parser for those strings. They will be freeform.
🦊 Another option is to keep the current options and add commands with the same names.
🐢 That will be confusing. The user will have both --param and param, and they will work differently.
🐇 We can have an add command that accepts the current options. Parsing will be done by clap just like now, but for a subcommand of dependency.
🐢 The full command will be something like xvc pipeline step --step-name preprocessing dependency add --params 'params.json::batch_size'
🐇 With shorter commands, it’s like xvc p s -s preprocessing d a --params 'params.json::batch_size', and this doesn’t look like ffmpeg monstrosities.
🐲 In any case, this is a backward-incompatible change. This should wait for v0.7 along with ECS changes.
🐢 ECS changes are not user-visible, but these are. Certainly needs a minor version update.
🐇 Then, okay, let’s keep the current ones for this version and think about updating them in a future version.
🐢 Okay. Let’s finish up and we’ll create a separate invisible subcommand to ask questions to the Xvc repo for completions.
🐇 We completed completions for the common command structure. Now, we need a way to show certain info after certain commands. A tab after xvc p r -p should show pipeline names, for example.
🐢 Umm, yeah. And these should be as quick as possible. They shouldn’t check Git or any other things.
🐇 I looked here and there, and the only working example I found is here: https://github.com/clap-rs/clap/blob/master/clap_complete/tests/testsuite/zsh.rs#L248 in clap_complete tests.
🐢 Let’s try to dive in. We can start by cloning the repo, I believe.