From e3a2a17e6d5f80e40e7808c9fa957d822eda1a66 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Fri, 27 Feb 2026 13:03:33 +1000 Subject: [PATCH 1/2] cli init --- cli/.gitignore | 1 + cli/Cargo.lock | 7 +++++++ cli/Cargo.toml | 8 ++++++++ cli/LICENSE | 22 ++++++++++++++++++++++ cli/src/main.rs | 8 ++++++++ cli/src/rocli/command.rs | 9 +++++++++ cli/src/rocli/mod.rs | 4 ++++ cli/src/rocli/parse.rs | 33 +++++++++++++++++++++++++++++++++ 8 files changed, 92 insertions(+) create mode 100644 cli/.gitignore create mode 100644 cli/Cargo.lock create mode 100644 cli/Cargo.toml create mode 100644 cli/LICENSE create mode 100644 cli/src/main.rs create mode 100644 cli/src/rocli/command.rs create mode 100644 cli/src/rocli/mod.rs create mode 100644 cli/src/rocli/parse.rs diff --git a/cli/.gitignore b/cli/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/cli/.gitignore @@ -0,0 +1 @@ +/target diff --git a/cli/Cargo.lock b/cli/Cargo.lock new file mode 100644 index 0000000..39b79c0 --- /dev/null +++ b/cli/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "snow" +version = "0.1.0" diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 0000000..cd81076 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "snow" +description = "NixOS Derivative" +version = "0.1.0" +authors = ["_cry64 "] +edition = "2024" + +[dependencies] diff --git a/cli/LICENSE b/cli/LICENSE new file mode 100644 index 0000000..331525b --- /dev/null +++ b/cli/LICENSE @@ -0,0 +1,22 @@ +MIT License + +Copyright (c) 2026 _cry64 (Emile Clark-Boman) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/cli/src/main.rs b/cli/src/main.rs new file mode 100644 index 0000000..cf6b426 --- /dev/null +++ b/cli/src/main.rs @@ -0,0 +1,8 @@ +use std::env; + +mod rocli; + +fn main() { + let args: Vec = env::args().collect(); + println!("Hello, world!"); +} diff --git a/cli/src/rocli/command.rs b/cli/src/rocli/command.rs new file mode 100644 index 0000000..9b8272b --- /dev/null +++ b/cli/src/rocli/command.rs @@ -0,0 +1,9 @@ +pub struct Command { + pub name: String, + pub version: Option, + + pub action: Action, + + pub subcommands: Vec, + pub flags: Vec, +} diff --git a/cli/src/rocli/mod.rs b/cli/src/rocli/mod.rs new file mode 100644 index 0000000..0949058 --- /dev/null +++ b/cli/src/rocli/mod.rs @@ -0,0 +1,4 @@ +mod command; +mod parse; + +pub use parse::normalize_args; diff --git a/cli/src/rocli/parse.rs b/cli/src/rocli/parse.rs new file mode 100644 index 0000000..c48b549 --- /dev/null +++ b/cli/src/rocli/parse.rs @@ -0,0 +1,33 @@ +/// Parse the GNU convention CLI argument syntax. +/// +/// # Examples +/// ```rs +/// assert!(parse(vec!["--flag=value"]) == vec!["--flag", "value"]); +/// assert!(parse(vec!["--flag value"]) == vec!["--flag", "value"]); +/// assert!(parse(vec!["-abe"]) == vec!["-a", "-b", "-e"]); +/// assert!(parse(vec!["-abef=32"]) == vec!["-a", "-b", "-e", "-f", "32"]); +/// ``` +/// +/// # Credit +/// Based on [github:ksk001100/seahorse `src/utils.rs`](https://github.com/ksk001100/seahorse/blob/master/src/utils.rs) +pub fn normalize_args(args: Vec) -> Vec { + args.iter().fold(Vec::::new(), |mut acc, el| { + if !el.starts_with('-') { + acc.push(el.to_owned()); + return acc; + } + + let mut split = el.splitn(2, '=').map(|s| s.to_owned()).collect(); + if el.starts_with("--") { + acc.append(&mut split); + } else { + let flags = split[0].chars().skip(1).map(|c| format!("-{c}")); + + acc.append(&mut flags.collect()); + if let Some(value) = split.get(1) { + acc.push(value.to_owned()); + } + } + acc + }) +} From 2e536d7040af58035c14cbc8e2ac95b785f6eec9 Mon Sep 17 00:00:00 2001 From: _cry64 Date: Thu, 5 Mar 2026 19:26:02 +1000 Subject: [PATCH 2/2] pin sops-nix (im oopid) --- flake.lock | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/flake.lock b/flake.lock index fc8e402..1f667d9 100644 --- a/flake.lock +++ b/flake.lock @@ -185,9 +185,30 @@ "microvm": "microvm", "nixpkgs": "nixpkgs", "nt": "nt", + "sops-nix": "sops-nix", "systems": "systems_3" } }, + "sops-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1772495394, + "narHash": "sha256-hmIvE/slLKEFKNEJz27IZ8BKlAaZDcjIHmkZ7GCEjfw=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "1d9b98a29a45abe9c4d3174bd36de9f28755e3ff", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + }, "spectrum": { "flake": false, "locked": {