[fix] incorrect command line layout
This commit is contained in:
parent
3d22cf0020
commit
88706b4198
2 changed files with 37 additions and 23 deletions
9
justfile
9
justfile
|
|
@ -1,4 +1,3 @@
|
|||
ui := "-i"
|
||||
verbose := "-v"
|
||||
file := "~/dev/lumina-iced/test_presentation.lisp"
|
||||
sdk-version := "25.08"
|
||||
|
|
@ -15,11 +14,11 @@ build-release:
|
|||
build-offline:
|
||||
cargo build --release --offline
|
||||
run:
|
||||
cargo run -- {{verbose}} {{ui}}
|
||||
cargo run -- {{verbose}}
|
||||
run-release:
|
||||
cargo run --release -- {{verbose}} {{ui}}
|
||||
cargo run --release -- {{verbose}}
|
||||
run-file:
|
||||
cargo run -- {{verbose}} {{ui}} {{file}}
|
||||
cargo run -- {{verbose}} cli {{file}}
|
||||
fix:
|
||||
cargo clippy --fix --bin "lumina" -p lumina -- -W clippy::pedantic -W clippy::perf -W clippy::nursery -W clippy::unwrap_used
|
||||
clean:
|
||||
|
|
@ -34,7 +33,7 @@ bench:
|
|||
export NEXTEST_EXPERIMENTAL_BENCHMARKS=1
|
||||
cargo nextest bench
|
||||
profile:
|
||||
samply record cargo run --release -- {{verbose}} {{ui}}
|
||||
samply record cargo run --release -- {{verbose}}
|
||||
|
||||
alias b := build
|
||||
alias r := run
|
||||
|
|
|
|||
51
src/main.rs
51
src/main.rs
|
|
@ -1,6 +1,6 @@
|
|||
#![allow(clippy::missing_panics_doc)]
|
||||
#![allow(clippy::missing_errors_doc)]
|
||||
use clap::Parser;
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use core::service_items::ServiceItem;
|
||||
use core::slide::{Background, BackgroundKind, Slide, SlideBuilder, TextAlignment};
|
||||
use cosmic::app::{Core, Settings, Task};
|
||||
|
|
@ -62,17 +62,27 @@ pub mod core;
|
|||
pub mod ui;
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
#[command(name = "lumina", version, about)]
|
||||
#[command(name = "lumina", version, about = "A church presentation app")]
|
||||
struct Cli {
|
||||
#[arg(short, long)]
|
||||
watch: bool,
|
||||
#[arg(short = 'i', long)]
|
||||
ui: bool,
|
||||
file: Option<PathBuf>,
|
||||
#[command(subcommand)]
|
||||
command: Option<Commands>,
|
||||
#[arg(short = 'v', long)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
#[derive(Subcommand, Debug, Clone)]
|
||||
#[command(version, about, long_about = None)]
|
||||
enum Commands {
|
||||
Cli(CliCommand),
|
||||
}
|
||||
|
||||
#[derive(Args, Debug, Clone)]
|
||||
struct CliCommand {
|
||||
#[arg(short, long)]
|
||||
watch: bool,
|
||||
file: Option<PathBuf>,
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let timer = tracing_subscriber::fmt::time::ChronoLocal::new(
|
||||
"%Y-%m-%d_%I:%M:%S%.6f %P".to_owned(),
|
||||
|
|
@ -116,18 +126,20 @@ fn main() -> Result<()> {
|
|||
}
|
||||
};
|
||||
|
||||
let settings = if args.ui {
|
||||
debug!(target: "lumina", "main view");
|
||||
Settings::default().debug(false).is_daemon(true)
|
||||
} else {
|
||||
let settings = if args.command.is_some_and(|command| match command {
|
||||
Commands::Cli(_) => true,
|
||||
}) {
|
||||
debug!("window view");
|
||||
Settings::default()
|
||||
.debug(false)
|
||||
.no_main_window(true)
|
||||
.is_daemon(true)
|
||||
} else {
|
||||
debug!(target: "lumina", "main view");
|
||||
Settings::default().debug(false).is_daemon(true)
|
||||
};
|
||||
|
||||
cosmic::app::run::<App>(settings, (args, config_handler, config))
|
||||
cosmic::app::run::<App>(settings, (Cli::parse(), config_handler, config))
|
||||
.map_err(|e| miette!("Invalid things... {}", e))
|
||||
}
|
||||
|
||||
|
|
@ -290,8 +302,11 @@ impl cosmic::Application for App {
|
|||
let fontdb = Arc::new(fontdb);
|
||||
|
||||
let mut windows = vec![];
|
||||
let cli_mode = input.0.command.is_some_and(|command| match command {
|
||||
Commands::Cli(_cli_command) => true,
|
||||
});
|
||||
|
||||
if input.0.ui {
|
||||
if !cli_mode {
|
||||
windows.push(core.main_window_id().expect("should be a window here"));
|
||||
}
|
||||
|
||||
|
|
@ -392,7 +407,7 @@ impl cosmic::Application for App {
|
|||
file: PathBuf::default(),
|
||||
windows,
|
||||
presentation_open: false,
|
||||
cli_mode: !input.0.ui,
|
||||
cli_mode,
|
||||
library: None,
|
||||
library_open: true,
|
||||
editor_mode: None,
|
||||
|
|
@ -423,12 +438,12 @@ impl cosmic::Application for App {
|
|||
let mut batch = vec![];
|
||||
batch.push(presenter_obs_task);
|
||||
|
||||
if input.0.ui {
|
||||
debug!("main view");
|
||||
batch.push(app.update_title());
|
||||
} else {
|
||||
if cli_mode {
|
||||
debug!("window view");
|
||||
batch.push(app.show_window());
|
||||
} else {
|
||||
debug!("main view");
|
||||
batch.push(app.update_title());
|
||||
}
|
||||
|
||||
batch.push(add_library());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue