cli cleanup and implement completion generation
This commit is contained in:
parent
de96002fdf
commit
8e9567e6e0
6 changed files with 63 additions and 27 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
|
@ -321,6 +321,15 @@ dependencies = [
|
|||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_complete"
|
||||
version = "4.5.65"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "430b4dc2b5e3861848de79627b2bedc9f3342c7da5173a14eaa5d0f8dc18ae5d"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "4.5.45"
|
||||
|
|
@ -1827,9 +1836,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "sway-de-utils"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap_complete",
|
||||
"confy",
|
||||
"dialog",
|
||||
"env_logger",
|
||||
|
|
|
|||
14
Cargo.toml
14
Cargo.toml
|
|
@ -1,10 +1,11 @@
|
|||
[package]
|
||||
name = "sway-de-utils"
|
||||
version = "0.1.6"
|
||||
version = "0.1.7"
|
||||
authors = ["Penelope Gwen <support@pogmom.me>"]
|
||||
edition = "2024"
|
||||
license-file = "LICENSE.md"
|
||||
description = "A collection of utility commands which help manage a multiple-workspace setup in Sway"
|
||||
build="build.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "sdu"
|
||||
|
|
@ -32,6 +33,17 @@ watchexec = "8.0.1"
|
|||
watchexec-events = "6.0.0"
|
||||
xdg = "3.0.0"
|
||||
|
||||
[build-dependencies]
|
||||
clap = { version = "4.5.45", features = ["derive", "cargo"] }
|
||||
clap_complete = "4.5.65"
|
||||
|
||||
[package.metadata.deb]
|
||||
#conflicts = ["sway-profiles"]
|
||||
changelog = "debian/changelog"
|
||||
assets = [
|
||||
"$auto",
|
||||
["target/release/build/sway-de-utils-*/out/sdu.bash", "/usr/share/bash-completion/completions/", "644"],
|
||||
["target/release/build/sway-de-utils-*/out/_sdu", "/usr/share/zsh/vendor_completions/", "644"],
|
||||
["target/release/build/sway-de-utils-*/out/sdu.fish", "/usr/share/fish/vendor_completions.d/", "644"],
|
||||
["target/release/build/sway-de-utils-*/out/sdu.elv", "/usr/share/elvish/lib/", "644"]
|
||||
]
|
||||
|
|
|
|||
28
build.rs
Normal file
28
build.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use clap::{CommandFactory, command};
|
||||
use clap_complete::{aot::Elvish, generate_to, shells::{Bash, Fish, Zsh}};
|
||||
use std::env;
|
||||
use std::io::Error;
|
||||
|
||||
include!("src/lib/cli.rs");
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let outdir = match env::var_os("OUT_DIR") {
|
||||
None => return Ok(()),
|
||||
Some(outdir) => outdir,
|
||||
};
|
||||
|
||||
let mut cmd = Cli::command();
|
||||
let bash_path = generate_to(
|
||||
Bash,
|
||||
&mut cmd, // We need to specify what generator to use
|
||||
"sdu", // We need to specify the bin name manually
|
||||
&outdir, // We need to specify where to write to
|
||||
)?;
|
||||
let zsh_path = generate_to(Zsh, &mut cmd, "sdu", &outdir)?;
|
||||
let fish_path = generate_to(Fish, &mut cmd, "sdu", &outdir)?;
|
||||
let elvish_path = generate_to(Elvish, &mut cmd, "sdu", outdir)?;
|
||||
|
||||
println!("cargo:warning=completion files were generated: [ {bash_path:?}, {zsh_path:?}, {fish_path:?}, {elvish_path:?} ]");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
6
debian/changelog
vendored
6
debian/changelog
vendored
|
|
@ -1,3 +1,9 @@
|
|||
sway-de-utils (0.1.7-1) unstable; urgency=medium
|
||||
|
||||
* implement shell completions for bash, fish, zsh
|
||||
|
||||
-- Penelope Gwen <support@pogmom.me> Sat, 24 Jan 2026 12:48:02 -0800
|
||||
|
||||
sway-de-utils (0.1.6-1) unstable; urgency=medium
|
||||
|
||||
* add retrieval of current workspace profile information for real this time
|
||||
|
|
|
|||
|
|
@ -1,24 +1,10 @@
|
|||
use clap::{ArgAction, Parser, Subcommand, ValueEnum};
|
||||
use clap_complete::aot::{generate, Generator, Shell};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
pub struct Cli {
|
||||
/// Disable truncation of window titles
|
||||
#[arg(short = 'T', long = "no-truncate-title", action = ArgAction::SetTrue)]
|
||||
no_truncate_title: Option<bool>,
|
||||
|
||||
/// Enables monitoring for supported event types
|
||||
#[arg(short = 'm', long = "monitor", action = ArgAction::SetTrue)]
|
||||
monitor: Option<bool>,
|
||||
|
||||
/// Turn debugging information on
|
||||
#[arg(short, long, action = ArgAction::Count)]
|
||||
debug: u8,
|
||||
|
||||
#[command(subcommand)]
|
||||
pub(crate) command: Commands,
|
||||
// command: Commands,
|
||||
}
|
||||
|
||||
#[derive(Subcommand)]
|
||||
|
|
@ -50,17 +36,8 @@ pub enum Commands {
|
|||
/// Lists global/profile shortcuts and optionally executes them
|
||||
#[clap(alias = "scut")]
|
||||
Shortcuts {
|
||||
/// List shortcuts from global shortcut list rather than
|
||||
// #[arg(short, long, action = ArgAction::SetTrue)]
|
||||
// global: Option<bool>,
|
||||
#[command(subcommand)]
|
||||
shortcut_command: ShortcutCommand,
|
||||
// /// Execute foud command
|
||||
// #[arg(short, long, action = ArgAction::SetTrue)]
|
||||
// execute: bool,
|
||||
// /// Mode to print shortcut information
|
||||
// #[command(subcommand)]
|
||||
// mode: Option<ShortcutMode>
|
||||
},
|
||||
/// List or Execute Power/Session Commands
|
||||
#[clap(alias = "pow")]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#![warn(unused_crate_dependencies)]
|
||||
//#![allow(clippy::style)]
|
||||
|
||||
|
||||
mod config;
|
||||
#[path = "lib/mod.rs"]
|
||||
mod lib;
|
||||
|
|
@ -9,8 +10,7 @@ use {
|
|||
crate::{
|
||||
config::Config,
|
||||
lib::{
|
||||
Cli, Commands, launch, lock_screen, power_fn, profile_fn, run_sway_command,
|
||||
shortcuts_fn, sway_fn, get_xdg_dirs, setup_runtime_dir,
|
||||
Cli, Commands, get_xdg_dirs, launch, lock_screen, power_fn, profile_fn, setup_runtime_dir, shortcuts_fn, sway_fn
|
||||
},
|
||||
|
||||
},
|
||||
|
|
@ -20,7 +20,10 @@ use {
|
|||
};
|
||||
|
||||
fn main() -> Result<(), ()> {
|
||||
let _build_script = include_str!("../Cargo.toml");
|
||||
let _build_script = include_str!("../Cargo.lock");
|
||||
env_logger::init();
|
||||
//Cli::command();
|
||||
let cli = Cli::parse();
|
||||
let config = if confy::get_configuration_file_path("sway-de-utils", "config")
|
||||
.expect("Unable to determine config file location")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue