๐Ÿข Now, the next version will have a --json output for xvc file list, we can start working on it or update Readme file?

๐Ÿ‡ What about adding at least command completions for nushell?

๐Ÿข Letโ€™s read a bit about clap_complete_nushell

๐ŸฆŠ There seems to be a nu-complete command. Letโ€™s check its documentation.

๐Ÿ‡ Nothing found and kagi doesnโ€™t help much either.

๐Ÿข There is a completions document for nushell: https://www.nushell.sh/book/custom_completions.html

๐Ÿ‡ There is a tool called carapace to provide completions across shells.

๐Ÿข Its documentation is thin and Iโ€™m not sure if it supports dynamic completions out of the box. I believe instead of adding a carapace setup, we can just write a nushell completion script that will use JSON output from the commands and add some (maybe hidden) utility commands to suport it.

๐Ÿ‡ There are a set of example scripts in nushell repo: https://github.com/nushell/nu_scripts/tree/main/custom-completions

๐Ÿข The reason I want to write custom completions for nushell is that it will be an exercise for the scripting language. gh completions are not that scary as a Bash script.

๐Ÿ‡ git completions are a better example for xvc. They simply run git whenever necessary. We can start from a static completions command and update this with dynamic completions manually. It will teach a lot.

๐Ÿข I forked the nu_scripts repo and will add xvc completions script there.

๐Ÿ‡ Then letโ€™s begin by adding nushell static completions. Shall we add a command for this?

๐ŸฆŠ Reviving the completion command we removed in 0.6.13?

๐Ÿข We shouldnโ€™t list it. We can make a _comp subcommand for the time being and generate and distribute completions in the repository. When clap_complete_nushell has the feature parity to provide dynamic completions, we can remove these commands.

๐Ÿ‡ What will we use this other than generating completions?

๐Ÿข Maybe dynamic completions can call this as well.

๐Ÿ‡ Added nushell static completions to be output using xvc _comp generate-nushell. Letโ€™s bump up the version to 0.6.15.

cargo set-version 0.6.15-alpha.1
   Upgrading xvc from 0.6.14 to 0.6.15-alpha.1
...
DEFAULT

๐Ÿข I noticed we forgot a line in cli command handler that asserts xvc_root_opt.is_some() and this fails when we run xvc outside of repositories. We need to release this version quickly.

๐Ÿ‡ Oops, now, ok, letโ€™s write a static nushell generator and just release quickly.

๐ŸฆŠ Generating completions with

xvc comp generate-nushell
DEFAULT

๐Ÿข Completion command is run with comp instead of _comp. Should we rename it?

๐Ÿ‡ Renamed it to _comp. Itโ€™s not hidden but at least we can be sure that it wonโ€™t be misunderstood as a common command.

๐Ÿข Bumping the version again. Now letโ€™s source the generated script and test it.

cargo set-version 0.6.15-alpha.2
   Upgrading xvc from 0.6.15-alpha.1 to 0.6.15-alpha.2
...
DEFAULT

๐ŸฆŠ Yep, it works. We now have completions for nushell.

๐Ÿข Letโ€™s update completions documentation.

๐Ÿ‡ Done. Now, letโ€™s take a look at CI and see what fails.

ghrl | first
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ conclusion   โ”‚ success                                                 โ”‚
โ”‚ displayTitle โ”‚ Add Nushell completions                                 โ”‚
โ”‚ headBranch   โ”‚ nushell-completions                                     โ”‚
โ”‚ url          โ”‚ https://github.com/iesahin/xvc/actions/runs/13070200765 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
NU

๐Ÿข It fails because of coverage, not the tests. Codecov says the new code isnโ€™t tested.

๐Ÿ‡ The added xvc _comp command isnโ€™t tested. We can add add a test running those lines and testing if the command outputs a completion script.

๐Ÿข We have a test for completions. We can add a test that runs the lines.

๐Ÿ‡ Added a test and bumping up the version.

cargo set-version 0.6.15-alpha.3
   Upgrading xvc from 0.6.15-alpha.2 to 0.6.15-alpha.3
...
NU

๐ŸฆŠ We can add some more coverage while waiting for the tests.

๐Ÿ‡ XvcOutputLine implementation seems to have no tests. Itโ€™s weird, because we use these everywhere.

๐Ÿข Iโ€™m not sure we use this particular implementations, we just use XvcOutputLine::Info(s), not XvcOutputLine::info(s) anywhere. We can delete these methods actually.

๐Ÿ‡ Weโ€™ll add JSON output via this particular struct. Can we refactor these to use formatting for JSON, for example? Or use these to output JSON?

๐ŸฆŠ We can add a formatter to XvcOutputLine to output structures.

๐Ÿข The enum is now defined as:

#[derive(Clone, Debug)]
pub enum XvcOutputLine {
    /// The output that we should be reporting to user
    Output(String),
    /// For informational messages
    Info(String),
    /// For debug output to show the internals of Xvc
    Debug(String),
    /// Warnings that are against some usual workflows
    Warn(String),
    /// Errors that interrupts a workflow but may be recoverable
    Error(String),
    /// Panics that interrupts the workflow and ends the program
    /// Note that this doesn't call panic! automatically
    Panic(String),
    /// Progress bar ticks.
    /// Self::Info is also used for Tick(1)
    Tick(usize),
}
RUST

Here, these fields can also have a formatter that will render the string in a particular format. For example the output can be

XvcOutputLine::Output(XvcJsonFormatter, String)
RUST

๐Ÿ‡ Iโ€™m not sure this is a good idea. Output already specifies this string as output. We can have a wrapper instead, like,

struct XvcJsonOutput(Format<XvcStructuredOutput>, XvcStructuredOutput)
RUST

and we can use the supplied format to render XvcStructuredOutput to an output line with XvcOutputLine::Output. If we donโ€™t provide output as structured, it will be too much error prone work to convert the current outputs to structured.

๐ŸฆŠ The transition will also be gradual. We may not need structured output for most of the commands. We can start with xvc file list and convert others as we go.

๐Ÿข This is sensible. By the way, coverage still didnโ€™t increase. There may something going on with codecov or running the test.

ghrl | first
โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚ conclusion   โ”‚ success                                                 โ”‚
โ”‚ displayTitle โ”‚ Add Nushell completions                                 โ”‚
โ”‚ headBranch   โ”‚ nushell-completions                                     โ”‚
โ”‚ url          โ”‚ https://github.com/iesahin/xvc/actions/runs/13087431038 โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
NU

๐Ÿ‡ Letโ€™s run the test:

cargo test -p xvc --test test_completions
...
test test_completions ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.80s
SH

๐Ÿข Can we make sure the output is a nushell script and not an error message?

๐Ÿ‡ Letโ€™s print it out.

๐Ÿข It looks when COMPLETE environment variable is set, it never calls _comp subcommand and never calls those lines.

cargo set-version 0.6.15-alpha.4
   Upgrading xvc from 0.6.15-alpha.3 to 0.6.15-alpha.4
...
DEFAULT

๐Ÿข Letโ€™s make a release for 0.6.15. Coverage is OK now.

cargo set-version 0.6.15
   Upgrading xvc from 0.6.15-alpha.4 to 0.6.15
...
NU
gh pr merge --squash --body $"(open CHANGELOG.md | lines | skip 2 | take 5)" --subject "Add static nushell completions"
NU

๐Ÿ‡ Merged the PR.

๐Ÿข Releases should appear in a few minutes.

๐Ÿ‡ We need to tag the merge commit for this.

๐Ÿข Oh, yep. AFAIK Lazygit doesnโ€™t have something for git push --tags. Letโ€™s push from the CLI.

git push --tags
You are on the main branch. Skipping CHANGELOG.md check.
To github.com:iesahin/xvc
 * [new tag]         v0.6.15 -> v0.6.15
NU

๐ŸฆŠ These commands, especially tables are not rendered correctly on the web. We need to change the theme I think.