chore: document somethings

This commit is contained in:
rvcas
2022-06-14 17:27:27 -04:00
parent 984c253f31
commit dc4246244d
7 changed files with 78 additions and 2 deletions

View File

@@ -2,21 +2,28 @@ use std::path::PathBuf;
use clap::{Parser, Subcommand};
/// Cardano smart contract toolchain
#[derive(Parser)]
#[clap(author, version, about, long_about = None)]
#[clap(propagate_version = true)]
pub enum Cli {
/// A subcommand for working with Untyped Plutus Core
#[clap(subcommand)]
Uplc(UplcCommand),
}
/// Commands for working with Untyped Plutus Core
#[derive(Subcommand)]
pub enum UplcCommand {
/// Encode textual Untyped Plutus Core to flat bytes
Flat {
input: PathBuf,
#[clap(short, long)]
print: bool,
#[clap(short, long)]
out: Option<String>,
},
/// Decode flat bytes to textual Untyped Plutus Core
Unflat {
input: PathBuf,
#[clap(short, long)]

View File

@@ -1,3 +1,5 @@
use std::fs;
use uplc::{
ast::{DeBruijn, FakeNamedDeBruijn, Program},
parser,
@@ -10,7 +12,7 @@ fn main() -> anyhow::Result<()> {
match args {
Cli::Uplc(uplc) => match uplc {
UplcCommand::Flat { input, print } => {
UplcCommand::Flat { input, print, out } => {
let code = std::fs::read_to_string(&input)?;
let program = parser::program(&code)?;
@@ -31,6 +33,14 @@ fn main() -> anyhow::Result<()> {
}
println!();
} else {
let out_name = if let Some(out) = out {
out
} else {
format!("{}.flat", input.file_stem().unwrap().to_str().unwrap())
};
fs::write(&out_name, &bytes)?;
}
}
UplcCommand::Unflat { input, print } => {