Skip to content

Commit d3c7544

Browse files
loungy CLI initial
1 parent 7cba833 commit d3c7544

File tree

17 files changed

+235
-16
lines changed

17 files changed

+235
-16
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ crossbeam-channel = "0.5.12"
7575
reqwest = "0.11.24"
7676
quick-xml = "0.31.0"
7777
scraper = "0.19.0"
78+
clap = { version = "4.5.7", features = ["cargo", "derive", "string"] }
7879

7980
[target.'cfg(target_os = "macos")'.dependencies]
8081
swift-rs = "1.0.6"

src/app.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,20 @@
99
*
1010
*/
1111

12+
use async_std::os::unix::net::UnixListener;
1213
use gpui::*;
1314

1415
use crate::{
1516
assets::Assets,
1617
commands::RootCommands,
1718
hotkey::HotkeyManager,
19+
ipc::server::start_server,
1820
theme::Theme,
1921
window::{Window, WindowStyle},
2022
workspace::Workspace,
2123
};
2224

23-
pub fn run_app(app: gpui::App) {
25+
pub fn run_app(listener: UnixListener, app: gpui::App) {
2426
app.with_assets(Assets).run(move |cx: &mut AppContext| {
2527
Theme::init(cx);
2628
// TODO: This still only works for a single display
@@ -37,6 +39,7 @@ pub fn run_app(app: gpui::App) {
3739
theme.window_background.clone().unwrap_or_default(),
3840
));
3941
RootCommands::init(cx);
42+
cx.spawn(|cx| start_server(listener, cx)).detach();
4043
HotkeyManager::init(cx);
4144
let view = Workspace::build(cx);
4245
Window::init(cx);
File renamed without changes.

src/commands/menu/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod list;

src/commands/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use std::collections::HashMap;
1313

1414
use gpui::*;
1515
use log::error;
16+
use serde::{Deserialize, Serialize};
1617

1718
use crate::{
1819
command,
@@ -27,28 +28,32 @@ use crate::{
2728
},
2829
};
2930

30-
#[cfg(target_os = "macos")]
31-
use self::root::menu;
32-
use self::root::{list, process, theme};
31+
use self::root::list;
3332

3433
#[cfg(feature = "bitwarden")]
3534
mod bitwarden;
3635
#[cfg(feature = "clipboard")]
3736
mod clipboard;
3837
#[cfg(feature = "matrix")]
3938
mod matrix;
39+
#[cfg(target_os = "macos")]
40+
mod menu;
41+
mod process;
4042
pub mod root;
4143
#[cfg(feature = "tailscale")]
4244
mod tailscale;
45+
mod theme;
4346

44-
#[derive(Clone)]
47+
#[derive(Clone, Serialize, Deserialize)]
4548
pub struct RootCommand {
4649
pub id: String,
4750
title: String,
4851
subtitle: String,
4952
icon: Icon,
5053
keywords: Vec<String>,
54+
#[serde(skip)]
5155
shortcut: Option<Shortcut>,
56+
#[serde(skip)]
5257
pub action: Box<dyn CloneableFn>,
5358
}
5459
impl RootCommand {
@@ -77,7 +82,7 @@ pub trait RootCommandBuilder: CommandTrait {
7782
fn build(&self, cx: &mut WindowContext) -> RootCommand;
7883
}
7984

80-
#[derive(Clone)]
85+
#[derive(Clone, Serialize, Deserialize)]
8186
pub struct RootCommands {
8287
pub commands: HashMap<String, RootCommand>,
8388
}
@@ -87,9 +92,9 @@ impl RootCommands {
8792
let commands: Vec<Box<dyn RootCommandBuilder>> = vec![
8893
Box::new(list::LoungyCommandBuilder),
8994
#[cfg(target_os = "macos")]
90-
Box::new(menu::MenuCommandBuilder),
91-
Box::new(process::ProcessCommandBuilder),
92-
Box::new(theme::ThemeCommandBuilder),
95+
Box::new(menu::list::MenuCommandBuilder),
96+
Box::new(process::list::ProcessCommandBuilder),
97+
Box::new(theme::list::ThemeCommandBuilder),
9398
#[cfg(feature = "tailscale")]
9499
Box::new(tailscale::list::TailscaleCommandBuilder),
95100
#[cfg(feature = "bitwarden")]
File renamed without changes.

src/commands/process/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub mod list;

src/commands/root/mod.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,4 @@
1010
*/
1111

1212
pub mod list;
13-
#[cfg(target_os = "macos")]
14-
pub mod menu;
1513
pub mod numbat;
16-
pub mod process;
17-
pub mod theme;
File renamed without changes.

0 commit comments

Comments
 (0)