Skip to content

Commit

Permalink
Support version option
Browse files Browse the repository at this point in the history
  • Loading branch information
magicant committed Sep 17, 2023
1 parent 5d2cbf1 commit 2a57df1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions yash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ pub use yash_syntax::{alias, parser, source, syntax};
pub mod startup;
// mod runner;

async fn parse_and_print(mut env: yash_env::Env) -> i32 {
async fn print_version(env: &mut env::Env) -> i32 {
use builtin::common::Print;
let version = env!("CARGO_PKG_VERSION");
let result = &env.print(&format!("yash {}\n", version)).await;
result.exit_status().0
}

async fn parse_and_print(mut env: env::Env) -> i32 {
use env::option::Option::{Interactive, Monitor};
use env::option::State::On;
use env::variable::Value::Array;
Expand All @@ -42,7 +49,7 @@ async fn parse_and_print(mut env: yash_env::Env) -> i32 {

let run = match startup::args::parse(std::env::args()) {
Ok(Parse::Help) => todo!("print help"),
Ok(Parse::Version) => todo!("print version"),
Ok(Parse::Version) => return print_version(&mut env).await,
Ok(Parse::Run(run)) => run,
Err(e) => {
let arg0 = std::env::args().next().unwrap_or_else(|| "yash".to_owned());
Expand Down

0 comments on commit 2a57df1

Please sign in to comment.