Spike, not the final UI: it answers whether flare-ui can drive Alkane OS's on-box pages, and what it costs. What works: - schema/alkane-bb.json authors the sidebar as data (3 sections, 14 tabs); - src/bin/ui-spike.rs renders it through flare_ui::nav + flare_ui::shell, so the unified sidebar, ordering and surface filtering come from the schema rather than from hand-written HTML; - the render uses the shared bf- design tokens, the same ones the rest of the suite uses. Size, measured rather than assumed (armv7, release, stripped): ui-baseline 323 KiB (maud + serde_json, no flare-ui) ui-spike 771 KiB (flare-ui + wschema + sha2) marginal 448 KiB Vendoring: third-party/flare-ui is the full v0.2.9 tree pinned in flare-ui/flare-ui.lock (a partial archive does not compile, since the crate include_str!s assets from dash-editor/). vendor/ is re-generated as a cargo directory source with the new registry dependencies (maud, sha2, typenum, digest, generic-array, block-buffer, crypto-common, cfg-if, etc.) so the build still works offline. third-party/README.md records how to re-pin.
81 lines
2.4 KiB
Rust
81 lines
2.4 KiB
Rust
#![allow(dead_code)]
|
|
use clap::error::{Error, ErrorKind};
|
|
use clap::{ArgMatches, Args as _, Command, FromArgMatches, Parser, Subcommand};
|
|
|
|
#[derive(Parser, Debug)]
|
|
struct AddArgs {
|
|
name: Vec<String>,
|
|
}
|
|
#[derive(Parser, Debug)]
|
|
struct RemoveArgs {
|
|
#[arg(short, long)]
|
|
force: bool,
|
|
name: Vec<String>,
|
|
}
|
|
|
|
#[derive(Debug)]
|
|
enum CliSub {
|
|
Add(AddArgs),
|
|
Remove(RemoveArgs),
|
|
}
|
|
|
|
impl FromArgMatches for CliSub {
|
|
fn from_arg_matches(matches: &ArgMatches) -> Result<Self, Error> {
|
|
match matches.subcommand() {
|
|
Some(("add", args)) => Ok(Self::Add(AddArgs::from_arg_matches(args)?)),
|
|
Some(("remove", args)) => Ok(Self::Remove(RemoveArgs::from_arg_matches(args)?)),
|
|
Some((_, _)) => Err(Error::raw(
|
|
ErrorKind::InvalidSubcommand,
|
|
"Valid subcommands are `add` and `remove`",
|
|
)),
|
|
None => Err(Error::raw(
|
|
ErrorKind::MissingSubcommand,
|
|
"Valid subcommands are `add` and `remove`",
|
|
)),
|
|
}
|
|
}
|
|
fn update_from_arg_matches(&mut self, matches: &ArgMatches) -> Result<(), Error> {
|
|
match matches.subcommand() {
|
|
Some(("add", args)) => *self = Self::Add(AddArgs::from_arg_matches(args)?),
|
|
Some(("remove", args)) => *self = Self::Remove(RemoveArgs::from_arg_matches(args)?),
|
|
Some((_, _)) => {
|
|
return Err(Error::raw(
|
|
ErrorKind::InvalidSubcommand,
|
|
"Valid subcommands are `add` and `remove`",
|
|
));
|
|
}
|
|
None => (),
|
|
};
|
|
Ok(())
|
|
}
|
|
}
|
|
|
|
impl Subcommand for CliSub {
|
|
fn augment_subcommands(cmd: Command) -> Command {
|
|
cmd.subcommand(AddArgs::augment_args(Command::new("add")))
|
|
.subcommand(RemoveArgs::augment_args(Command::new("remove")))
|
|
.subcommand_required(true)
|
|
}
|
|
fn augment_subcommands_for_update(cmd: Command) -> Command {
|
|
cmd.subcommand(AddArgs::augment_args(Command::new("add")))
|
|
.subcommand(RemoveArgs::augment_args(Command::new("remove")))
|
|
.subcommand_required(true)
|
|
}
|
|
fn has_subcommand(name: &str) -> bool {
|
|
matches!(name, "add" | "remove")
|
|
}
|
|
}
|
|
|
|
#[derive(Parser, Debug)]
|
|
struct Cli {
|
|
#[arg(short, long)]
|
|
top_level: bool,
|
|
#[command(subcommand)]
|
|
subcommand: CliSub,
|
|
}
|
|
|
|
fn main() {
|
|
let args = Cli::parse();
|
|
println!("{args:#?}");
|
|
}
|