mirror of https://github.com/jdx/mise
docs: add individual page for every CLI command
This commit is contained in:
parent
fff2253200
commit
53b0223950
|
@ -1,3 +1,4 @@
|
|||
registry/
|
||||
target/
|
||||
CHANGELOG.md
|
||||
docs/node_modules/
|
||||
|
|
|
@ -0,0 +1,265 @@
|
|||
// This file is generated by `mise render-help`
|
||||
// Do not edit this file directly
|
||||
|
||||
export type Command = {
|
||||
hide: boolean,
|
||||
subcommands?: {
|
||||
[key: string]: Command,
|
||||
},
|
||||
};
|
||||
export const commands: { [key: string]: Command } = {
|
||||
"activate": {
|
||||
hide: false,
|
||||
},
|
||||
"alias": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"get": {
|
||||
hide: false,
|
||||
},
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
"set": {
|
||||
hide: false,
|
||||
},
|
||||
"unset": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"asdf": {
|
||||
hide: true,
|
||||
},
|
||||
"backends": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"bin-paths": {
|
||||
hide: false,
|
||||
},
|
||||
"cache": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"clear": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"completion": {
|
||||
hide: false,
|
||||
},
|
||||
"config": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
"generate": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"current": {
|
||||
hide: false,
|
||||
},
|
||||
"deactivate": {
|
||||
hide: false,
|
||||
},
|
||||
"direnv": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"envrc": {
|
||||
hide: true,
|
||||
},
|
||||
"exec": {
|
||||
hide: true,
|
||||
},
|
||||
"activate": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"doctor": {
|
||||
hide: false,
|
||||
},
|
||||
"env": {
|
||||
hide: false,
|
||||
},
|
||||
"exec": {
|
||||
hide: false,
|
||||
},
|
||||
"generate": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"git-pre-commit": {
|
||||
hide: false,
|
||||
},
|
||||
"github-action": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"global": {
|
||||
hide: true,
|
||||
},
|
||||
"hook-env": {
|
||||
hide: true,
|
||||
},
|
||||
"hook-not-found": {
|
||||
hide: true,
|
||||
},
|
||||
"implode": {
|
||||
hide: false,
|
||||
},
|
||||
"install": {
|
||||
hide: false,
|
||||
},
|
||||
"latest": {
|
||||
hide: false,
|
||||
},
|
||||
"link": {
|
||||
hide: false,
|
||||
},
|
||||
"local": {
|
||||
hide: true,
|
||||
},
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
"ls-remote": {
|
||||
hide: false,
|
||||
},
|
||||
"outdated": {
|
||||
hide: false,
|
||||
},
|
||||
"plugins": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"install": {
|
||||
hide: false,
|
||||
},
|
||||
"link": {
|
||||
hide: false,
|
||||
},
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
"ls-remote": {
|
||||
hide: false,
|
||||
},
|
||||
"uninstall": {
|
||||
hide: false,
|
||||
},
|
||||
"update": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"prune": {
|
||||
hide: false,
|
||||
},
|
||||
"registry": {
|
||||
hide: false,
|
||||
},
|
||||
"render-help": {
|
||||
hide: true,
|
||||
},
|
||||
"render-mangen": {
|
||||
hide: true,
|
||||
},
|
||||
"reshim": {
|
||||
hide: false,
|
||||
},
|
||||
"run": {
|
||||
hide: false,
|
||||
},
|
||||
"self-update": {
|
||||
hide: false,
|
||||
},
|
||||
"set": {
|
||||
hide: false,
|
||||
},
|
||||
"settings": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"get": {
|
||||
hide: false,
|
||||
},
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
"set": {
|
||||
hide: false,
|
||||
},
|
||||
"unset": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"shell": {
|
||||
hide: false,
|
||||
},
|
||||
"sync": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"node": {
|
||||
hide: false,
|
||||
},
|
||||
"python": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"tasks": {
|
||||
hide: false,
|
||||
subcommands: {
|
||||
"deps": {
|
||||
hide: false,
|
||||
},
|
||||
"edit": {
|
||||
hide: false,
|
||||
},
|
||||
"ls": {
|
||||
hide: false,
|
||||
},
|
||||
"run": {
|
||||
hide: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
"trust": {
|
||||
hide: false,
|
||||
},
|
||||
"uninstall": {
|
||||
hide: false,
|
||||
},
|
||||
"unset": {
|
||||
hide: false,
|
||||
},
|
||||
"upgrade": {
|
||||
hide: false,
|
||||
},
|
||||
"usage": {
|
||||
hide: false,
|
||||
},
|
||||
"use": {
|
||||
hide: false,
|
||||
},
|
||||
"version": {
|
||||
hide: false,
|
||||
},
|
||||
"watch": {
|
||||
hide: false,
|
||||
},
|
||||
"where": {
|
||||
hide: false,
|
||||
},
|
||||
"which": {
|
||||
hide: false,
|
||||
},
|
||||
};
|
|
@ -1,4 +1,5 @@
|
|||
import { defineConfig } from 'vitepress'
|
||||
import { Command, commands } from './cli_commands'
|
||||
|
||||
// https://vitepress.dev/reference/site-config
|
||||
export default defineConfig({
|
||||
|
@ -100,7 +101,8 @@ export default defineConfig({
|
|||
text: 'CLI Reference',
|
||||
link: '/cli/',
|
||||
items: [
|
||||
{ text: 'Global Flags', link: '/cli/global-flags' }
|
||||
{text: 'Global Flags', link: '/cli/global-flags'},
|
||||
...cliReference(commands),
|
||||
]
|
||||
},
|
||||
],
|
||||
|
@ -150,3 +152,24 @@ export default defineConfig({
|
|||
]
|
||||
],
|
||||
})
|
||||
|
||||
function cliReference(commands: { [key: string]: Command }) {
|
||||
return Object.keys(commands)
|
||||
.map((name) => [name, commands[name]] as [string, Command])
|
||||
.filter(([name, command]) => command.hide !== true)
|
||||
.map(([name, command]) => {
|
||||
const x: any = {
|
||||
text: name,
|
||||
};
|
||||
if (command.subcommands) {
|
||||
x.collapsed = true;
|
||||
x.items = Object.keys(command.subcommands).map((subcommand) => ({
|
||||
text: subcommand,
|
||||
link: `/cli/${name}/${subcommand}`,
|
||||
}));
|
||||
} else {
|
||||
x.link = `/cli/${name}`;
|
||||
}
|
||||
return x;
|
||||
})
|
||||
}
|
||||
|
|
|
@ -17,9 +17,9 @@ directory. Other projects on your machine can use a different set of versions.
|
|||
mise is inspired by [asdf](https://asdf-vm.com) and uses asdf's
|
||||
vast [plugin ecosystem](https://github.com/rtx-plugins/registry)
|
||||
under the hood. However, it is _much_ faster than asdf and has a more friendly user experience.
|
||||
For more on how mise compares to asdf, [see below](./comparison-to-asdf). See available plugins for
|
||||
For more on how mise compares to asdf, [see below](./comparison-to-asdf). See plugins available for
|
||||
mise with
|
||||
[`mise plugins ls-remote`](https://mise.jdx.dev/cli/#mise-plugins-ls-remote-options).
|
||||
[`mise plugins ls-remote`](/cli/plugins/ls-remote).
|
||||
|
||||
mise can be configured in many ways. The most typical is by `.mise.toml`, but it's also compatible
|
||||
with asdf `.tool-versions` files. It can also use idiomatic version files like `.node-version` and
|
||||
|
@ -65,7 +65,7 @@ for each command to go to its reference documentation page to see all available
|
|||
more
|
||||
examples.
|
||||
|
||||
### [`mise use`](https://mise.jdx.dev/cli/#mise-use-options-tool-version)
|
||||
### [`mise use`](/cli/use)
|
||||
|
||||
For some users, `mise use` might be the only command you need to learn. It will do the following:
|
||||
|
||||
|
@ -83,7 +83,7 @@ unless there is a config file in the local directory hierarchy, node-20 will be
|
|||
for
|
||||
the user.
|
||||
|
||||
### [`mise install`](https://mise.jdx.dev/cli/#mise-install-options-tool-version)
|
||||
### [`mise install`](/cli/install)
|
||||
|
||||
`mise install` will install but not activate tools—meaning it will download/build/compile the tool
|
||||
into `~/.local/share/mise/installs` but you won't be able to use it without "setting" the version
|
||||
|
@ -111,7 +111,7 @@ These are hidden from the CLI help and remain for asdf-compatibility. The recomm
|
|||
to use `mise use` instead because that will do the same thing but also install the tool if it does
|
||||
not already exists.
|
||||
|
||||
### [`mise exec`|`mise x`](https://mise.jdx.dev/cli/#mise-use-options-tool-version)
|
||||
### [`mise exec`|`mise x`](/cli/exec)
|
||||
|
||||
`mise x` can be used for one-off commands using specific tools. e.g.: if you want to run a script
|
||||
with python3.12:
|
||||
|
|
|
@ -62,7 +62,7 @@ never modify PATH because it never displays a prompt. For this type of setup, yo
|
|||
`mise hook-env` manually every time you wish to update PATH, or use [shims](/dev-tools/shims.md)
|
||||
instead (preferred).
|
||||
Or if you only need to use mise for certain commands, just prefix the commands with
|
||||
[`mise x --`](./cli/#mise-exec-options-tool-version-command).
|
||||
[`mise x --`](./cli/exec).
|
||||
For example, `mise x -- npm test` or `mise x -- ./my_script.sh`.
|
||||
|
||||
`mise hook-env` will exit early in different situations if no changes have been made. This prevents
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -25,6 +25,7 @@ impl RenderHelp {
|
|||
doc.push_str(current_readme.next().unwrap());
|
||||
doc = remove_trailing_spaces(&doc) + "\n";
|
||||
file::write("docs/cli/index.md", &doc)?;
|
||||
file::write("docs/.vitepress/cli_commands.ts", render_command_ts())?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
@ -120,6 +121,61 @@ fn remove_trailing_spaces(s: &str) -> String {
|
|||
.join("\n")
|
||||
}
|
||||
|
||||
fn render_command_ts() -> String {
|
||||
let mut doc = String::new();
|
||||
doc.push_str(&formatdoc! {r#"
|
||||
// This file is generated by `mise render-help`
|
||||
// Do not edit this file directly
|
||||
|
||||
export type Command = {{
|
||||
hide: boolean,
|
||||
subcommands?: {{
|
||||
[key: string]: Command,
|
||||
}},
|
||||
}};
|
||||
"#});
|
||||
doc.push_str("export const commands: { [key: string]: Command } = {\n");
|
||||
let mut cli = Cli::command()
|
||||
.term_width(80)
|
||||
.max_term_width(80)
|
||||
.disable_help_subcommand(true)
|
||||
.disable_help_flag(true);
|
||||
for command in cli
|
||||
.get_subcommands_mut()
|
||||
.sorted_by_cached_key(|c| c.get_name().to_string())
|
||||
{
|
||||
match command.has_subcommands() {
|
||||
true => {
|
||||
let name = command.get_name().to_string();
|
||||
doc.push_str(&format!(
|
||||
" \"{}\": {{\n hide: {},\n subcommands: {{\n",
|
||||
name,
|
||||
command.is_hide_set()
|
||||
));
|
||||
for subcommand in command.get_subcommands_mut() {
|
||||
let output = format!(
|
||||
" \"{}\": {{\n hide: {},\n }},\n",
|
||||
subcommand.get_name(),
|
||||
subcommand.is_hide_set()
|
||||
);
|
||||
doc.push_str(&output);
|
||||
}
|
||||
doc.push_str(" },\n },\n");
|
||||
}
|
||||
false => {
|
||||
let output = format!(
|
||||
" \"{}\": {{\n hide: {},\n }},\n",
|
||||
command.get_name(),
|
||||
command.is_hide_set()
|
||||
);
|
||||
doc.push_str(&output);
|
||||
}
|
||||
}
|
||||
}
|
||||
doc.push_str("};\n");
|
||||
doc
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use std::fs;
|
||||
|
|
Loading…
Reference in New Issue