-
Notifications
You must be signed in to change notification settings - Fork 537
Add cli2 plugin wrapping official cli plugin #1757
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7b69615
Add default CLI plugin config to tauri.conf.json
yujonglee f95e450
cli args support
yujonglee 4112e36
Extract Tauri CLI handler into standalone plugin
yujonglee b6f605b
update lock
yujonglee 079442e
Add CLI handler to process help/version and subcommands
yujonglee 2582630
replace opener
yujonglee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Based on `plugins/cli`, you might need to update: | ||
| - `apps/web/content/docs/cli.mdx` | ||
| - `apps/desktop/src-tauri/tauri.conf.json` | ||
|
|
||
| Ref: https://v2.tauri.app/plugin/cli |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| title: CLI | ||
| description: Learn how to use CLI in Hyprnote | ||
| --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| /.vs | ||
| .DS_Store | ||
| .Thumbs.db | ||
| *.sublime* | ||
| .idea/ | ||
| debug.log | ||
| package-lock.json | ||
| .vscode/settings.json | ||
| yarn.lock | ||
|
|
||
| /.tauri | ||
| /target | ||
| Cargo.lock | ||
| node_modules/ | ||
|
|
||
| dist-js | ||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| [package] | ||
| name = "tauri-plugin-cli2" | ||
| version = "0.1.0" | ||
| authors = ["You"] | ||
| edition = "2021" | ||
| exclude = ["/js", "/node_modules"] | ||
| links = "tauri-plugin-cli2" | ||
| description = "" | ||
|
|
||
| [build-dependencies] | ||
| tauri-plugin = { workspace = true, features = ["build"] } | ||
|
|
||
| [dev-dependencies] | ||
| specta-typescript = { workspace = true } | ||
|
|
||
| [dependencies] | ||
| tauri = { workspace = true, features = ["test"] } | ||
| tauri-plugin-cli = { workspace = true } | ||
| tauri-specta = { workspace = true, features = ["derive", "typescript"] } | ||
|
|
||
| serde = { workspace = true } | ||
| specta = { workspace = true } | ||
|
|
||
| open = { workspace = true } | ||
| thiserror = { workspace = true } | ||
| tracing = { workspace = true } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| const COMMANDS: &[&str] = &["install_cli", "uninstall_cli", "check_cli_status"]; | ||
|
|
||
| fn main() { | ||
| tauri_plugin::Builder::new(COMMANDS).build(); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| // @ts-nocheck | ||
|
|
||
|
|
||
| // This file was generated by [tauri-specta](https://github.com/oscartbeaumont/tauri-specta). Do not edit this file manually. | ||
|
|
||
| /** user-defined commands **/ | ||
|
|
||
|
|
||
| export const commands = { | ||
| async installCli() : Promise<Result<null, string>> { | ||
| try { | ||
| return { status: "ok", data: await TAURI_INVOKE("plugin:cli2|install_cli") }; | ||
| } catch (e) { | ||
| if(e instanceof Error) throw e; | ||
| else return { status: "error", error: e as any }; | ||
| } | ||
| }, | ||
| async uninstallCli() : Promise<Result<null, string>> { | ||
| try { | ||
| return { status: "ok", data: await TAURI_INVOKE("plugin:cli2|uninstall_cli") }; | ||
| } catch (e) { | ||
| if(e instanceof Error) throw e; | ||
| else return { status: "error", error: e as any }; | ||
| } | ||
| }, | ||
| async checkCliStatus() : Promise<Result<CliStatus, string>> { | ||
| try { | ||
| return { status: "ok", data: await TAURI_INVOKE("plugin:cli2|check_cli_status") }; | ||
| } catch (e) { | ||
| if(e instanceof Error) throw e; | ||
| else return { status: "error", error: e as any }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** user-defined events **/ | ||
|
|
||
|
|
||
|
|
||
| /** user-defined constants **/ | ||
|
|
||
|
|
||
|
|
||
| /** user-defined types **/ | ||
|
|
||
| export type CliStatus = { isInstalled: boolean; symlinkPath: string | null; targetPath: string | null } | ||
|
|
||
| /** tauri-specta globals **/ | ||
|
|
||
| import { | ||
| invoke as TAURI_INVOKE, | ||
| Channel as TAURI_CHANNEL, | ||
| } from "@tauri-apps/api/core"; | ||
| import * as TAURI_API_EVENT from "@tauri-apps/api/event"; | ||
| import { type WebviewWindow as __WebviewWindow__ } from "@tauri-apps/api/webviewWindow"; | ||
|
|
||
| type __EventObj__<T> = { | ||
| listen: ( | ||
| cb: TAURI_API_EVENT.EventCallback<T>, | ||
| ) => ReturnType<typeof TAURI_API_EVENT.listen<T>>; | ||
| once: ( | ||
| cb: TAURI_API_EVENT.EventCallback<T>, | ||
| ) => ReturnType<typeof TAURI_API_EVENT.once<T>>; | ||
| emit: null extends T | ||
| ? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit> | ||
| : (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>; | ||
| }; | ||
|
|
||
| export type Result<T, E> = | ||
| | { status: "ok"; data: T } | ||
| | { status: "error"; error: E }; | ||
|
|
||
| function __makeEvents__<T extends Record<string, any>>( | ||
| mappings: Record<keyof T, string>, | ||
| ) { | ||
| return new Proxy( | ||
| {} as unknown as { | ||
| [K in keyof T]: __EventObj__<T[K]> & { | ||
| (handle: __WebviewWindow__): __EventObj__<T[K]>; | ||
| }; | ||
| }, | ||
| { | ||
| get: (_, event) => { | ||
| const name = mappings[event as keyof T]; | ||
|
|
||
| return new Proxy((() => {}) as any, { | ||
| apply: (_, __, [window]: [__WebviewWindow__]) => ({ | ||
| listen: (arg: any) => window.listen(name, arg), | ||
| once: (arg: any) => window.once(name, arg), | ||
| emit: (arg: any) => window.emit(name, arg), | ||
| }), | ||
| get: (_, command: keyof __EventObj__<any>) => { | ||
| switch (command) { | ||
| case "listen": | ||
| return (arg: any) => TAURI_API_EVENT.listen(name, arg); | ||
| case "once": | ||
| return (arg: any) => TAURI_API_EVENT.once(name, arg); | ||
| case "emit": | ||
| return (arg: any) => TAURI_API_EVENT.emit(name, arg); | ||
| } | ||
| }, | ||
| }); | ||
| }, | ||
| }, | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export * from "./bindings.gen"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| { | ||
| "name": "@hypr/plugin-cli2", | ||
| "private": true, | ||
| "main": "./js/index.ts", | ||
| "scripts": { | ||
| "codegen": "cargo test -p tauri-plugin-cli2" | ||
| }, | ||
| "dependencies": { | ||
| "@tauri-apps/api": "^2.9.0" | ||
| } | ||
| } |
13 changes: 13 additions & 0 deletions
13
plugins/cli2/permissions/autogenerated/commands/check_cli_status.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Automatically generated - DO NOT EDIT! | ||
|
|
||
| "$schema" = "../../schemas/schema.json" | ||
|
|
||
| [[permission]] | ||
| identifier = "allow-check-cli-status" | ||
| description = "Enables the check_cli_status command without any pre-configured scope." | ||
| commands.allow = ["check_cli_status"] | ||
|
|
||
| [[permission]] | ||
| identifier = "deny-check-cli-status" | ||
| description = "Denies the check_cli_status command without any pre-configured scope." | ||
| commands.deny = ["check_cli_status"] |
13 changes: 13 additions & 0 deletions
13
plugins/cli2/permissions/autogenerated/commands/install_cli.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Automatically generated - DO NOT EDIT! | ||
|
|
||
| "$schema" = "../../schemas/schema.json" | ||
|
|
||
| [[permission]] | ||
| identifier = "allow-install-cli" | ||
| description = "Enables the install_cli command without any pre-configured scope." | ||
| commands.allow = ["install_cli"] | ||
|
|
||
| [[permission]] | ||
| identifier = "deny-install-cli" | ||
| description = "Denies the install_cli command without any pre-configured scope." | ||
| commands.deny = ["install_cli"] |
13 changes: 13 additions & 0 deletions
13
plugins/cli2/permissions/autogenerated/commands/uninstall_cli.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Automatically generated - DO NOT EDIT! | ||
|
|
||
| "$schema" = "../../schemas/schema.json" | ||
|
|
||
| [[permission]] | ||
| identifier = "allow-uninstall-cli" | ||
| description = "Enables the uninstall_cli command without any pre-configured scope." | ||
| commands.allow = ["uninstall_cli"] | ||
|
|
||
| [[permission]] | ||
| identifier = "deny-uninstall-cli" | ||
| description = "Denies the uninstall_cli command without any pre-configured scope." | ||
| commands.deny = ["uninstall_cli"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.