Initial WIP

This commit is contained in:
Dandaedre 2023-05-17 15:39:38 +02:00
parent e64c763a9b
commit c1f739598a
4 changed files with 81 additions and 0 deletions

5
.gitignore vendored
View File

@ -14,3 +14,8 @@ Cargo.lock
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# Added by cargo
/target

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "snp"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
clap = { version = "4.2.7", features = ["derive"] }
serde = { version = "1.0.163", features = ["derive"] }

8
TODO.md Normal file
View File

@ -0,0 +1,8 @@
## Features
### --new (name)
- Create a new snippet with given name at the default location (where tho ?)
### name args
- Use the snippet name with one or more args
- Args must be split up
-

58
src/main.rs Normal file
View File

@ -0,0 +1,58 @@
use clap::Parser;
use serde::{Deserialize, Serialize};
#[derive(Parser, Debug)]
#[command(author, version, about)]
struct Cli {
#[arg()]
snipplet: String,
#[arg(long, default_value_t = false)]
create: bool,
#[arg(help = "List of args to give to the snipplet")]
args: Vec<String>,
}
fn main() {
let cli = Cli::parse();
match cli.create {
true => create_snippet(),
false => print_snipped(),
}
println!("{:?}", cli);
}
/// A snippet ready to be Serialized/Deserialized
#[derive(Deserialize, Serialize)]
pub struct Snippet {
/// Akin to path, the name of the snippet is where to store it
name: String,
/// The default value of all args
args: Vec<String>,
/// The base string to format
string: String,
}
impl Snippet {
/// Create a new snippet
pub fn new(name: String, args: Vec<String>, string: String) -> Self {
Snippet { name, args, string }
}
/// Save the snippet at the default location under it's name
pub fn save(&self) -> Result<(), ()> {
Ok(())
}
/// Write to stdout the snipped with either default arguments or given arguments
pub fn print(&self) -> Result<(), ()> {
Ok(())
}
}
// pub struct AccessError{
// }