This commit is contained in:
Arthur Beck 2025-05-06 17:00:51 -05:00
parent d6d6df7298
commit 154281cfca
2 changed files with 52 additions and 3 deletions

View file

@ -16,9 +16,40 @@ fn main() {
.text([bold("sesh"), roman(" [options]")])
.control("SH", ["DESCRIPTION"])
.text([
bold("sesh"),
roman("is a shell designed to be as semantic to use as possible"),
bold("Sesh"),
roman(
"is a shell designed to be as semantic to use as possible. It isn't completely compatible\
with sh(yet) however the point is for it to be easily usable and understandable by humans. It can\
interpret commands from standard input or from a file."
),
])
.control("SH", ["OPTIONS"])
.text([
bold("-c, --run"), roman("\tIf this option is present, then commands are read from the\
argument provided to it and executed in a non-interactive environment(a shell will not be opened after\
they are done executing).\n"),
bold("-b, --before"), roman("\tIf this option is present, then commands are read from the\
argument provided to it and executed in an interactive environment(a shell WILL be opened after they\
are done executing).\n")
])
.control("SH", ["ARGUMENTS"])
.text(
[
roman("If arguments remain after option processing and neither -c nor -b have been supplied,\
the first argument is assumed to be the name of a shell file.")
]
)
.control("SH", ["FILES"])
.text(
[
bold("Sesh"), roman(" reads from and writes to a couple of files depending on the circumstances:\n\
.seshrc - Executed upon startup \n\
.sesh_history - Contains commands previously ran, one per line. Read upon startup in an interactive shell and\
written to after each command.\n\
Other files - Scripts may write to files via other methods, including outside tools. Scripts may be read from\
the path in the first argument of the shell after options.")
]
)
.render();
std::fs::write(
PathBuf::from(env::var_os("OUT_DIR").unwrap())

View file

@ -4,6 +4,7 @@
#![feature(cfg_match)]
#![feature(slice_concat_trait)]
#![feature(test)]
#![feature(let_chains)]
use std::{
ffi::OsStr,
@ -426,7 +427,24 @@ fn log_file(value: &str) {
#[allow(clippy::arc_with_non_send_sync)]
fn main() -> Result<(), Box<dyn std::error::Error>> {
let options = Args::parse();
let mut options = Args::parse();
if let Some(filename) = std::env::args().next() && options.run_before.is_empty() && options.run_expr.is_empty() {
let rc = std::fs::read(filename.clone());
if rc.is_err() {
println!("sesh: reading {} failed: {}", filename, rc.unwrap_err());
println!("sesh: exiting")
} else {
let rc = String::from_utf8(rc.unwrap());
if rc.is_err() {
println!("sesh: reading {} failed: not valid UTF-8", filename);
println!("sesh: exiting")
} else {
let rc = rc.unwrap();
options.run_expr = rc;
}
}
}
let mut state = State {
shell_env: Vec::new(),