Skip to content

Commit

Permalink
feat: start cli
Browse files Browse the repository at this point in the history
  • Loading branch information
nothendev committed Sep 25, 2023
1 parent 249847d commit 21f89ed
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
members = [
"protocol",
"server",
"cli"
]
resolver = "2"

Expand Down
7 changes: 7 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "oxcr_cli"
version = "0.1.0"
edition = "2021"

[dependencies]
oxcr_protocol.workspace = true
32 changes: 32 additions & 0 deletions cli/src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Spanned-clap, lol

use std::path::PathBuf;

use aott::prelude::*;
use oxcr_protocol::{aott, bytes::Bytes};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum CliSerOp {
Encode,
Decode,
}

#[derive(Debug, Clone)]
pub enum CliSerOperand {
File(PathBuf),
Data(Bytes),
}

#[derive(Debug, Clone)]
pub struct CliSer {
pub operation: CliSerOp,
pub operand: CliSerOperand,
}

#[derive(Debug, Clone)]
pub enum Cli {
Serialization(CliSer),
}

#[parser(extras = Extra)]
pub fn yay(input: &str) -> Cli {}
28 changes: 28 additions & 0 deletions cli/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use oxcr_protocol::{
aott,
miette::{self, SourceSpan},
ser::any_of,
thiserror,
};

#[derive(miette::Diagnostic, thiserror::Error, Debug)]
pub enum ParseErrorKind {
#[error("expected {expected}, found {found}")]
Expected { expected: Expectation, found: char },
#[error("unexpected end of input")]
UnexpectedEof,
}

#[derive(Debug, thiserror::Error)]
pub enum Expectation {
#[error("{}", any_of(.0))]
AnyOf(Vec<char>),
#[error("end of input")]
EndOfInput,
}

#[derive(miette::Diagnostic, thiserror::Error, Debug)]
pub struct ParseError {
#[label = "here"]
pub span: SourceSpan,
}
15 changes: 15 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
use oxcr_protocol::miette::Report;

mod cli;
mod error;

fn run() -> Result<(), Report> {
let mut args = std::env::args();

match args.next() {
None => panic!("what"),
Some(path) => {
let arguments: String = args.collect();
}
}
}

0 comments on commit 21f89ed

Please sign in to comment.