From 9acc0abe153086fe733f01cb35447e153e5f4d42 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 11 Aug 2024 16:45:37 -0300 Subject: [PATCH 1/2] feat: autogenerate CLI command docs --- package.json | 3 +- packages/cli-generator/build.ts | 98 ++++ packages/cli-generator/package.json | 21 + packages/cli-generator/tsconfig.json | 8 + pnpm-lock.yaml | 136 +++++- pnpm-workspace.yaml | 1 + src/content/docs/reference/.gitignore | 1 + src/content/docs/reference/_cli.mdx | 32 ++ src/content/docs/reference/cli.mdx | 666 -------------------------- 9 files changed, 295 insertions(+), 671 deletions(-) create mode 100644 packages/cli-generator/build.ts create mode 100644 packages/cli-generator/package.json create mode 100644 packages/cli-generator/tsconfig.json create mode 100644 src/content/docs/reference/_cli.mdx delete mode 100644 src/content/docs/reference/cli.mdx diff --git a/package.json b/package.json index 7398691c37..174b2dac31 100644 --- a/package.json +++ b/package.json @@ -15,9 +15,10 @@ "build:references": "pnpm --filter js-api-generator run build", "build:releases": "pnpm --filter releases-generator run build", "build:config": "pnpm --filter config-generator run build", + "build:cli": "pnpm --filter cli-generator run build", "build:astro": "astro build", "build:i18n": "pnpm --filter docs-i18n-tracker run build", - "build": "pnpm dev:setup && pnpm build:references && pnpm build:config && pnpm build:releases && pnpm build:astro && pnpm build:i18n", + "build": "pnpm dev:setup && pnpm build:references && pnpm build:config && pnpm build:cli && pnpm build:releases && pnpm build:astro && pnpm build:i18n", "preview": "astro preview" }, "dependencies": { diff --git a/packages/cli-generator/build.ts b/packages/cli-generator/build.ts new file mode 100644 index 0000000000..1de89f2085 --- /dev/null +++ b/packages/cli-generator/build.ts @@ -0,0 +1,98 @@ +import { readFileSync, writeFileSync } from 'node:fs'; +import { execSync } from 'node:child_process'; +import { slug } from 'github-slugger'; + +interface Command { + name: string; + description: string; +} + +function getSubcommands(commandOutput: string): Command[] { + const subcommands = []; + + let readingSubcommands = false; + for (const line of commandOutput.split('\n').map((l) => l.trim())) { + if (readingSubcommands) { + if (line.length === 0) { + readingSubcommands = false; + } else { + const subcommand = line.substring(0, line.indexOf(' ')); + const description = line.substring(subcommand.length).trim(); + if (subcommand !== 'help') { + subcommands.push({ name: subcommand, description }); + } + } + } + if (line === 'Commands:') { + readingSubcommands = true; + } + } + + return subcommands; +} + +function generateCommandDoc(command: string, level: number, subcommandList: Command[]): string { + const output = execSync(`pnpm tauri ${command} --help`).toString().replace('pnpm tauri', 'tauri'); + const subcommands = getSubcommands(output); + + subcommandList.push( + ...subcommands.map((subcommand) => ({ + ...subcommand, + name: `${command} ${subcommand.name}`, + })) + ); + + const subcommandsDoc = + subcommands.length === 0 + ? '' + : `\n${subcommands.map(({ name }) => generateCommandDoc(`${command} ${name}`, level + 1, commandList)).join('\n\n')}`; + + const heading = '#'.repeat(level); + return `${heading} \`${command}\` + + + +\`\`\` +${output} +\`\`\` +${subcommandsDoc} +`; +} + +const output = execSync('pnpm tauri --help').toString(); +const subcommands = getSubcommands(output); + +const commandList: Command[] = []; + +let doc = ''; + +for (const command of subcommands) { + commandList.push(command); + const commandDoc = generateCommandDoc(command.name, 3, commandList); + doc += commandDoc; +} + +let summary = `| Command | Description | +| ---------- | ------------------- | +`; + +for (const { name, description } of commandList) { + summary += `| [\`${name}\`](#${slug(name)}) | ${description} |\n`; +} + +const template = readFileSync('../../src/content/docs/reference/_cli.mdx').toString(); + +writeFileSync( + '../../src/content/docs/reference/cli.mdx', + template.replace( + '$LIST_OF_COMMANDS', + `${summary} + +${doc}` + ) +); diff --git a/packages/cli-generator/package.json b/packages/cli-generator/package.json new file mode 100644 index 0000000000..1fe8d8b18d --- /dev/null +++ b/packages/cli-generator/package.json @@ -0,0 +1,21 @@ +{ + "name": "cli-generator", + "version": "1.0.0", + "private": "true", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "build": "tsm ./build.ts" + }, + "keywords": [], + "author": "", + "license": "MIT", + "dependencies": { + "@tauri-apps/cli": "2.0.0-rc.3", + "@types/node": "^20.11.20", + "github-slugger": "^2.0.0", + "tsm": "^2.3.0", + "typescript": "^5.3.3" + } +} diff --git a/packages/cli-generator/tsconfig.json b/packages/cli-generator/tsconfig.json new file mode 100644 index 0000000000..e70b1b2dab --- /dev/null +++ b/packages/cli-generator/tsconfig.json @@ -0,0 +1,8 @@ +{ + "compilerOptions": { + "target": "ES2021", + "esModuleInterop": true, + "strict": true, + "skipLibCheck": true + } +} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index dd6e1be5f4..baf93a195f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -71,6 +71,24 @@ importers: specifier: ^0.10.0 version: 0.10.1(@astrojs/starlight@0.24.5(patch_hash=kv7yo3q5mkk7b2of2xzi4btao4)(astro@4.13.3(@types/node@22.2.0)(sass@1.77.8)(terser@5.31.0)(typescript@5.5.4)))(astro@4.13.3(@types/node@22.2.0)(sass@1.77.8)(terser@5.31.0)(typescript@5.5.4)) + packages/cli-generator: + dependencies: + '@tauri-apps/cli': + specifier: 2.0.0-rc.3 + version: 2.0.0-rc.3 + '@types/node': + specifier: ^20.11.20 + version: 20.14.15 + github-slugger: + specifier: ^2.0.0 + version: 2.0.0 + tsm: + specifier: ^2.3.0 + version: 2.3.0 + typescript: + specifier: ^5.3.3 + version: 5.5.4 + packages/config-generator: dependencies: '@types/json-schema': @@ -1273,6 +1291,71 @@ packages: '@surma/rollup-plugin-off-main-thread@2.2.3': resolution: {integrity: sha512-lR8q/9W7hZpMWweNiAKU7NQerBnzQQLvi8qnTDU/fxItPhtZVMbPV3lbCwjhIlNBe9Bbr5V+KHshvWmVSG9cxQ==} + '@tauri-apps/cli-darwin-arm64@2.0.0-rc.3': + resolution: {integrity: sha512-szYCSr/ChbCF+S6Wnr15TYpI2cZR07d+AQOiFGuScP0preM8Pbsk/sb0hfLwqzepjVFFNVWQba9sG7FEW2Y2XA==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@tauri-apps/cli-darwin-x64@2.0.0-rc.3': + resolution: {integrity: sha512-BJv6EJOY1DJbRzVtfg8CcBAlnS5OjhBAc5YKjh4BT7EyOcop8HStBSxhL6yjWrUP7eLR1iIsW/uSehVJwzYIdQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-rc.3': + resolution: {integrity: sha512-fwx805/xL4sF/EdMYqcUHQHzMYwo+OVTBTz5x/JWK8D57rnmLHAP+ZhnfFsZQLRo2QRT2l1Ye3bDyU+QRA1JFA==} + engines: {node: '>= 10'} + cpu: [arm] + os: [linux] + + '@tauri-apps/cli-linux-arm64-gnu@2.0.0-rc.3': + resolution: {integrity: sha512-3KauzO1Ls4kuY0nr82S4X8XFxlQAMN+Mqp8LLqvQ+PPMp92XQAkPH7osQdoHIEoW5gsE69U2JaiQ5tHSqNM9og==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@tauri-apps/cli-linux-arm64-musl@2.0.0-rc.3': + resolution: {integrity: sha512-ngHS0foffm1xO5gqnDKGeYMKj8ceGmrFP5dDldoaaMQubw1SyFa0pRUjb7fZSYiO7F4SOSa8NYeMqlF9peZmnQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@tauri-apps/cli-linux-x64-gnu@2.0.0-rc.3': + resolution: {integrity: sha512-0/am9pVvuUHGmz32M8ffz1fpLnc08j3nzcRe5wUdL2AxfT+wKMII+Dn99GtCVgcdDW4jSXDMRUwrBkGocGC2OA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@tauri-apps/cli-linux-x64-musl@2.0.0-rc.3': + resolution: {integrity: sha512-r7mRi8q8TqTFVjb9kAsU7IgwUgno2s8Ip4xwq9psQhlRE3JGEZQmSEcy1jqTjfl6KFh6lJcDR7l+9/EMhL/D3Q==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@tauri-apps/cli-win32-arm64-msvc@2.0.0-rc.3': + resolution: {integrity: sha512-2J6KjmDIQCw6HF1X6/yPcd+JLl7pxrH2zVMGmNllaoWhHeByvRobqFWnT7gcdHaA3dGTo432CwWvOgTgrINQpQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@tauri-apps/cli-win32-ia32-msvc@2.0.0-rc.3': + resolution: {integrity: sha512-8q75CsHDSEDdgi6xPwim+BaQZFCswK2Dn/qL38V3Mh9kmVvC8oGJMPC66bC20dF+v3KWeFm2FNNGQqOSXCveHg==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + + '@tauri-apps/cli-win32-x64-msvc@2.0.0-rc.3': + resolution: {integrity: sha512-qeBRJYalahxEXolekcpZJ/HBrIJacG2NWJBGhhi797mIwnbmlpbHMc8blIJtNNNwVUb2BjXuxKQVfojQ5YYrcg==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@tauri-apps/cli@2.0.0-rc.3': + resolution: {integrity: sha512-iNF95pieBmverl1EmQyqh+fhcIClS544fN5Ex5lAbYLTiHZ/gm3lOfVBhF6NPaKd/sfLuy7K1tfDXlHztBfANw==} + engines: {node: '>= 10'} + hasBin: true + '@types/acorn@4.0.6': resolution: {integrity: sha512-veQTnWP+1D/xbxVrPC3zHnCZRjSrKfhbMUlEA43iMZLu7EsnTtkJklIuwrCPbOi8YkvDQAiW05VQQFvvz9oieQ==} @@ -5119,6 +5202,49 @@ snapshots: magic-string: 0.25.9 string.prototype.matchall: 4.0.11 + '@tauri-apps/cli-darwin-arm64@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-darwin-x64@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-linux-arm-gnueabihf@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-linux-arm64-gnu@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-linux-arm64-musl@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-linux-x64-gnu@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-linux-x64-musl@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-win32-arm64-msvc@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-win32-ia32-msvc@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli-win32-x64-msvc@2.0.0-rc.3': + optional: true + + '@tauri-apps/cli@2.0.0-rc.3': + optionalDependencies: + '@tauri-apps/cli-darwin-arm64': 2.0.0-rc.3 + '@tauri-apps/cli-darwin-x64': 2.0.0-rc.3 + '@tauri-apps/cli-linux-arm-gnueabihf': 2.0.0-rc.3 + '@tauri-apps/cli-linux-arm64-gnu': 2.0.0-rc.3 + '@tauri-apps/cli-linux-arm64-musl': 2.0.0-rc.3 + '@tauri-apps/cli-linux-x64-gnu': 2.0.0-rc.3 + '@tauri-apps/cli-linux-x64-musl': 2.0.0-rc.3 + '@tauri-apps/cli-win32-arm64-msvc': 2.0.0-rc.3 + '@tauri-apps/cli-win32-ia32-msvc': 2.0.0-rc.3 + '@tauri-apps/cli-win32-x64-msvc': 2.0.0-rc.3 + '@types/acorn@4.0.6': dependencies: '@types/estree': 1.0.5 @@ -5187,16 +5313,17 @@ snapshots: '@types/node@22.2.0': dependencies: undici-types: 6.13.0 + optional: true '@types/resolve@1.17.1': dependencies: - '@types/node': 22.2.0 + '@types/node': 20.14.15 '@types/retry@0.12.2': {} '@types/sax@1.2.7': dependencies: - '@types/node': 17.0.45 + '@types/node': 20.14.15 '@types/trusted-types@2.0.7': {} @@ -6505,7 +6632,7 @@ snapshots: jest-worker@26.6.2: dependencies: - '@types/node': 22.2.0 + '@types/node': 20.14.15 merge-stream: 2.0.0 supports-color: 7.2.0 @@ -8003,7 +8130,8 @@ snapshots: undici-types@5.26.5: {} - undici-types@6.13.0: {} + undici-types@6.13.0: + optional: true unicode-canonical-property-names-ecmascript@2.0.0: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 46e2ae91db..9310e0c71f 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -2,5 +2,6 @@ packages: - 'packages/i18n-tracker' - 'packages/js-api-generator' - 'packages/config-generator' + - 'packages/cli-generator' - 'packages/tauri-typedoc-theme' - 'packages/releases-generator' diff --git a/src/content/docs/reference/.gitignore b/src/content/docs/reference/.gitignore index 8f0e898675..ab8924aded 100644 --- a/src/content/docs/reference/.gitignore +++ b/src/content/docs/reference/.gitignore @@ -1,4 +1,5 @@ config.md acl/*.md +cli.mdx javascript/* !javascript/index.mdx diff --git a/src/content/docs/reference/_cli.mdx b/src/content/docs/reference/_cli.mdx new file mode 100644 index 0000000000..6820d3a68e --- /dev/null +++ b/src/content/docs/reference/_cli.mdx @@ -0,0 +1,32 @@ +--- +title: Command Line Interface +sidebar: + order: 1 +tableOfContents: + minHeadingLevel: 2 + maxHeadingLevel: 5 +--- + +import { Tabs, TabItem } from '@astrojs/starlight/components'; +import CommandTabs from '@components/CommandTabs.astro'; + +The Tauri command line interface (CLI) is the way to interact with Tauri throughout the development lifecycle. + +You can add the Tauri CLI to your current project using your package manager of choice: + + + +:::tip[Developing a Plugin] + +For CLI commands related to developing plugins visit the [Develop a Tauri Plugin guide](/develop/plugins/). + +::: + +## List of Commands + +$LIST_OF_COMMANDS diff --git a/src/content/docs/reference/cli.mdx b/src/content/docs/reference/cli.mdx deleted file mode 100644 index 468343197c..0000000000 --- a/src/content/docs/reference/cli.mdx +++ /dev/null @@ -1,666 +0,0 @@ ---- -title: Command Line Interface -sidebar: - order: 1 ---- - -import { Tabs, TabItem } from '@astrojs/starlight/components'; -import CommandTabs from '@components/CommandTabs.astro'; - -The Tauri command line interface (CLI) is the way to interact with Tauri throughout the development lifecycle. - -You can add the Tauri CLI to your current project using your package manager of choice: - - -{/* TODO: 2.0 */} - -:::tip[Developing a Plugin] - -For CLI commands related to developing plugins visit the [Develop a Tauri Plugin guide](/develop/plugins/). - -::: - -## List of Commands - -| Command | Description | -| ----------------------------- | -------------------------------------------------------------------- | -| [`build`](#build) | Tauri build | -| [`dev`](#dev) | Tauri dev | -| [`icon`](#icon) | Generates various icons for all major platforms | -| [`info`](#info) | Shows information about Tauri dependencies and project configuration | -| [`init`](#init) | Initializes a Tauri project | -| [`add`](#add) | Manage Tauri plugins | -| [`signer`](#signer) | Tauri updater signer | -| [`completions`](#completions) | Shell completions | -| [`ios`](#ios) | iOS commands | -| [`android`](#android) | Android commands | -| [`migrate`](#migrate) | Migrate from v1 to v2 | -| [`permission`](#permission) | Manage permissions | -| [`capability`](#capability) | Manage permissions | -| [`help`](#help) | Print this message or the help of the given subcommand(s) | - -## `build` - - - -``` -Tauri build - -Usage: cargo tauri build [OPTIONS] [ARGS]... - -Arguments: - [ARGS]... - Command line arguments passed to the runner - -Options: - -r, --runner - Binary to use to build the application, defaults to `cargo` - -v, --verbose... - Enables verbose logging - -d, --debug - Builds with the debug flag - -t, --target - Target triple to build against. - It must be one of the values outputted by `$rustc --print target-list` or `universal-apple-darwin` for an universal macOS application. - Note that compiling an universal macOS application requires both `aarch64-apple-darwin` and `x86_64-apple-darwin` targets to be installed. - -f, --features [...] - Space or comma separated list of features to activate - -b, --bundles [...] - Space or comma separated list of bundles to package. - Each bundle must be one of `deb`, `appimage`, `msi`, `app` or `dmg` on MacOS and `updater` on all platforms. - Note that the `updater` bundle is not automatically added so you must specify it if the updater is enabled. - --no-bundle - Bundler will be skipped - -c, --config - JSON string or path to JSON file to merge with tauri.conf.json - --ci - Skip prompting for values - -h, --help - Print help (see a summary with '-h') - -V, --version - Print version -``` - -## `dev` - - - -``` -Tauri dev - -Usage: cargo tauri dev [OPTIONS] [ARGS]... - -Arguments: - [ARGS]... Command line arguments passed to the runner. Arguments after `--` are passed to the application - -Options: - -r, --runner Binary to use to run the application - -v, --verbose... Enables verbose logging - -t, --target Target triple to build against - -f, --features [...] List of cargo features to activate - -e, --exit-on-panic Exit on panic - -c, --config JSON string or path to JSON file to merge with tauri.conf.json - --release Run the code in release mode - --no-watch Disable the file watcher - --no-dev-server Disable the dev server for static files - --port Specify port for the dev server for static files. Defaults to 1430 Can also be set using `TAURI_DEV_SERVER_PORT` env var - --force-ip-prompt Force prompting for an IP to use to connect to the dev server on mobile - -h, --help Print help - -V, --version Print version -``` - -This command will open the WebView in development mode. It makes use of the `build.devPath` property from your `tauri.conf.json` file. - -If you have entered a command to the `build.beforeDevCommand` property, this one will be executed before the dev command. - -## `icon` - - - -``` -Generates various icons for all major platforms - -Usage: cargo tauri icon [OPTIONS] [INPUT] - -Arguments: - [INPUT] Path to the source icon (png, 1240x1240px with transparency) [default: ./app-icon.png] - -Options: - -o, --output Output directory. Default: 'icons' directory next to the tauri.conf.json file - -v, --verbose... Enables verbose logging - -p, --png Custom PNG icon sizes to generate. When set, the default icons are not generated - --ios-color The background color of the iOS icon - string as defined in the W3C's CSS Color Module Level 4 [default: #fff] - -h, --help Print help - -V, --version Print version -``` - -## `info` - - - -``` -Shows information about Tauri dependencies and project configuration - -Usage: cargo tauri info [OPTIONS] - -Options: - --interactive Interactive mode to apply automatic fixes - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -`tauri info` shows a concise list of information about the environment, Rust, Node.js and their versions as well as a few relevant project configurations. - -## `init` - - - -``` -Initializes a Tauri project - -Usage: cargo tauri init [OPTIONS] - -Options: - --ci - Skip prompting for values - -v, --verbose... - Enables verbose logging - -f, --force - Force init to overwrite the src-tauri folder - -l, --log - Enables logging - -d, --directory - Set target directory for init [default: C:\Users\Fabian-Lars] - -t, --tauri-path - Path of the Tauri project to use (relative to the cwd) - -A, --app-name - Name of your Tauri application - -W, --window-title - Window title of your Tauri application - -D, --dist-dir - Web assets location, relative to /src-tauri - -P, --dev-path - Url of your dev server - --before-dev-command - A shell command to run before `tauri dev` kicks in - --before-build-command - A shell command to run before `tauri build` kicks in - -h, --help - Print help - -V, --version - Print version -``` - -## `add` - - - -``` -Installs a plugin on the project - -Usage: cargo tauri add [OPTIONS] - -Arguments: - The plugin to add - -Options: - -t, --tag Git tag to use - -v, --verbose... Enables verbose logging - -r, --rev Git rev to use - -b, --branch Git branch to use - -h, --help Print help - -V, --version Print version -``` - -## `signer` - - - -``` -Tauri updater signer - -Usage: cargo tauri signer [OPTIONS] - -Commands: - sign Sign a file - generate Generate keypair to sign files - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -## `completions` - - - -``` -Shell completions - -Usage: cargo tauri completions [OPTIONS] --shell - -Options: - -s, --shell Shell to generate a completion script for. [possible values: bash, elvish, fish, powershell, zsh] - -v, --verbose... Enables verbose logging - -o, --output Output file for the shell completions. By default the completions are printed to stdout - -h, --help Print help - -V, --version Print version -``` - -The Tauri CLI can generate shell completions for Bash, Zsh, PowerShell and Fish. - -Here are some instructions to configure Bash, Zsh and PowerShell. If you face an issue, please follow your shell's instructions instead. Note that it is recommended to check the generated completions script before executing it for security reasons. - -### Bash - -Get the Bash completions and move to a known folder: - - - - -```shell -npm run tauri completions -- --shell bash > tauri.sh -mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash -``` - - - - -```shell -yarn tauri completions --shell bash > tauri.sh -mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash -``` - - - - -```shell -pnpm tauri completions --shell bash > tauri.sh -mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash -``` - - - - -```shell -cargo tauri completions --shell bash > tauri.sh -mv tauri.sh /usr/local/etc/bash_completion.d/tauri.bash -``` - - - - -Load the completions script by adding the following to `.bashrc`: - -```shell -source /usr/local/etc/bash_completion.d/tauri.bash -``` - -### Zsh - -Get the Zsh completions and move to a known folder: - - - - -```shell -npm run tauri completions -- --shell zsh > completions.zsh -mv completions.zsh $HOME/.completions/_tauri -``` - - - - -```shell -yarn tauri completions --shell zsh > completions.zsh -mv completions.zsh $HOME/.completions/_tauri -``` - - - - -```shell -pnpm tauri completions --shell zsh > completions.zsh -mv completions.zsh $HOME/.completions/_tauri -``` - - - - -```shell -cargo tauri completions --shell zsh > completions.zsh -mv completions.zsh $HOME/.completions/_tauri -``` - - - - -Load the completions folder using fpath adding the following to `.zshrc`: - -```shell -fpath=(~/.completions $fpath) -autoload -U compinit -``` - -### PowerShell - -Get the PowerShell completions and add it to the `$profile` file to execute it on all sessions: - - - - -```powershell -npm run tauri completions -- --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1") -Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"' -``` - - - - -```powershell -yarn tauri completions --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1") -Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"' -``` - - - - -```powershell -pnpm tauri completions --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1") -Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"' -``` - - - - -```powershell -cargo tauri completions --shell powershell > ((Split-Path -Path $profile)+"\_tauri.ps1") -Add-Content -Path $profile -Value '& "$PSScriptRoot\_tauri.ps1"' -``` - - - - -## `android` - - - -``` -Android commands - -Usage: cargo tauri android [OPTIONS] - -Commands: - init Initializes a Tauri Android project - open Open project in Android Studio - dev Android dev - build Android build - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -## `ios` - - - -``` -iOS commands - -Usage: cargo tauri ios [OPTIONS] - -Commands: - init Initializes a Tauri iOS project - open Open project in Xcode - dev iOS dev - build iOS build - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -## `migrate` - - - -``` -Migrate from v1 to v2 - -Usage: cargo tauri migrate [OPTIONS] - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -## `permission` - - - -``` -Permission commands - -Usage: cargo tauri permission - -Commands: - new Create a new permission file - add Add a permission to capabilities - rm Remove a permission file, and its reference from any capability - ls List permissions available to your application -``` - -### `new` - -Create a new permission file - -``` -Arguments: - [IDENTIFIER] Permission identifier - -Options: - --description \ Permission description - -v, --verbose... Enables verbose logging - -a, --allow \ List of commands to allow - -d, --deny \ List of commands to deny - --format \ Output file format [default: json] [possible values: json, toml] - -o, --out \ The output file - -h, --help Print help - -V, --version Print version -``` - -### `add` - -Add a permission to capabilities - -``` -Arguments: - Permission to add - [CAPABILITY] Capability to add the permission to - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -### `rm` - -Remove a permission file, and its reference from any capability - -``` -Arguments: - Permission to remove - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -### `ls` - -List permissions available to your application - -``` -Arguments: - [PLUGIN] Name of the plugin to list permissions - -Options: - -f, --filter \ Permission identifier filter - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version - -``` - -## `capability` - - - -``` -Migrate from v1 to v2 - -Usage: cargo tauri capability [OPTIONS] - -Commands: - new Create a new permission file - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` - -### `new` - -`Usage: cargo tauri capability new [OPTIONS] [IDENTIFIER]` - -``` -Arguments: - [IDENTIFIER] Capability identifier - -Options: - --description Capability description - -v, --verbose... Enables verbose logging - --windows Capability windows - --permission Capability permissions - --format Output file format [default: json] [possible values: json, toml] - -o, --out The output file - -h, --help Print help - -V, --version Print version -``` - -## `help` - - - -``` -Command line interface for building Tauri apps - -Usage: cargo tauri [OPTIONS] - -Commands: - build Tauri build - dev Tauri dev - icon Generates various icons for all major platforms - info Shows information about Tauri dependencies and project configuration - init Initializes a Tauri project - plugin Manage Tauri plugins - signer Tauri updater signer - completions Shell completions - android Android commands - ios iOS commands - migrate Migrate from v1 to v2 - help Print this message or the help of the given subcommand(s) - -Options: - -v, --verbose... Enables verbose logging - -h, --help Print help - -V, --version Print version -``` From 88e52a4de89ce3f6c49dd6f37bbee76290492c36 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sun, 11 Aug 2024 17:25:34 -0300 Subject: [PATCH 2/2] fix usage doc --- packages/cli-generator/build.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/cli-generator/build.ts b/packages/cli-generator/build.ts index 1de89f2085..42571275a2 100644 --- a/packages/cli-generator/build.ts +++ b/packages/cli-generator/build.ts @@ -32,7 +32,9 @@ function getSubcommands(commandOutput: string): Command[] { } function generateCommandDoc(command: string, level: number, subcommandList: Command[]): string { - const output = execSync(`pnpm tauri ${command} --help`).toString().replace('pnpm tauri', 'tauri'); + const output = execSync(`pnpm tauri ${command} --help`) + .toString() + .replace('pnpm run build', 'tauri'); const subcommands = getSubcommands(output); subcommandList.push(