Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .cursor/commands/manage-cli.md
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
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ tauri-plugin-updater = "2.9"
tauri-plugin-analytics = { path = "plugins/analytics" }
tauri-plugin-apple-calendar = { path = "plugins/apple-calendar" }
tauri-plugin-auth = { path = "plugins/auth" }
tauri-plugin-cli2 = { path = "plugins/cli2" }
tauri-plugin-db = { path = "plugins/db" }
tauri-plugin-db2 = { path = "plugins/db2" }
tauri-plugin-detect = { path = "plugins/detect" }
Expand Down Expand Up @@ -157,6 +158,7 @@ indoc = "2"
itertools = "0.14.0"
lazy_static = "1.5.0"
once_cell = "1.20.3"
open = "5"
regex = "1.11.1"
schemars = "0.8.21"
serde = "1"
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"@hypr/codemirror": "workspace:^",
"@hypr/db": "workspace:*",
"@hypr/plugin-analytics": "workspace:*",
"@hypr/plugin-cli2": "workspace:*",
"@hypr/plugin-db2": "workspace:*",
"@hypr/plugin-detect": "workspace:*",
"@hypr/plugin-hooks": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tauri-plugin-analytics = { workspace = true }
tauri-plugin-auth = { workspace = true }
tauri-plugin-autostart = { workspace = true }
tauri-plugin-cli = { workspace = true }
tauri-plugin-cli2 = { workspace = true }
tauri-plugin-clipboard-manager = { workspace = true }
tauri-plugin-db2 = { workspace = true }
tauri-plugin-deep-link = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions apps/desktop/src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"tray:default",
"auth:default",
"analytics:default",
"cli2:default",
"updater:default",
"deep-link:default",
"store:default",
Expand Down
11 changes: 1 addition & 10 deletions apps/desktop/src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod store;
use ext::*;
use store::*;

use tauri_plugin_cli::CliExt;
use tauri_plugin_windows::{AppWindow, WindowsPluginExt};

#[tokio::main]
Expand Down Expand Up @@ -46,6 +45,7 @@ pub async fn main() {

builder = builder
.plugin(tauri_plugin_cli::init())
.plugin(tauri_plugin_cli2::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_auth::init())
Expand Down Expand Up @@ -90,15 +90,6 @@ pub async fn main() {
.invoke_handler(specta_builder.invoke_handler())
.on_window_event(tauri_plugin_windows::on_window_event)
.setup(move |app| {
match app.cli().matches() {
Ok(matches) => {
println!("{matches:?}");
}
Err(error) => {
println!("failed to read CLI matches: {error}");
}
}

let app_handle = app.handle().clone();

let app_clone = app_handle.clone();
Expand Down
9 changes: 9 additions & 0 deletions apps/desktop/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@
}
},
"plugins": {
"cli": {
"description": "Hyprnote",
"args": [],
"subcommands": {
"hello": {
"description": "Open https://hyprnote.com"
}
}
},
"deep-link": {
"desktop": {
"schemes": [
Expand Down
4 changes: 4 additions & 0 deletions apps/web/content/docs/cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
title: CLI
description: Learn how to use CLI in Hyprnote
---
17 changes: 17 additions & 0 deletions plugins/cli2/.gitignore
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
26 changes: 26 additions & 0 deletions plugins/cli2/Cargo.toml
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 }
5 changes: 5 additions & 0 deletions plugins/cli2/build.rs
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();
}
106 changes: 106 additions & 0 deletions plugins/cli2/js/bindings.gen.ts
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);
}
},
});
},
},
);
}
1 change: 1 addition & 0 deletions plugins/cli2/js/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./bindings.gen";
11 changes: 11 additions & 0 deletions plugins/cli2/package.json
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"
}
}
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 plugins/cli2/permissions/autogenerated/commands/install_cli.toml
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 plugins/cli2/permissions/autogenerated/commands/uninstall_cli.toml
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"]
Loading
Loading