Added dirname command; Fix wrap for base32; Various cleanups;
This commit is contained in:
parent
2510f80303
commit
2bce4afe7a
BIN
pkg/bin/shitbox
Executable file
BIN
pkg/bin/shitbox
Executable file
Binary file not shown.
38
pkg/usr/share/man/man1/base32.1
Normal file
38
pkg/usr/share/man/man1/base32.1
Normal file
@ -0,0 +1,38 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH base32 1 "base32 0.1.0"
|
||||
.SH NAME
|
||||
base32 \- Base32 encode/decode data and print to standard output
|
||||
.SH SYNOPSIS
|
||||
\fBbase32\fR [\fB\-d\fR|\fB\-\-decode\fR] [\fB\-i\fR|\fB\-\-ignore\-space\fR] [\fB\-w\fR|\fB\-\-wrap\fR] [\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-q\fR|\fB\-\-quiet\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIINPUT\fR]
|
||||
.SH DESCRIPTION
|
||||
Base32 encode/decode data and print to standard output
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-d\fR, \fB\-\-decode\fR
|
||||
Decode rather than encode
|
||||
.TP
|
||||
\fB\-i\fR, \fB\-\-ignore\-space\fR
|
||||
Ignore whitespace when decoding
|
||||
.TP
|
||||
\fB\-w\fR, \fB\-\-wrap\fR [default: 76]
|
||||
Wrap encoded lines after n characters
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Display a header naming each file
|
||||
.TP
|
||||
\fB\-q\fR, \fB\-\-quiet\fR
|
||||
Do not display header, even with multiple files
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.TP
|
||||
[\fIINPUT\fR]
|
||||
The input file to use
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
The JeanG3nie <jeang3nie@hitchhiker\-linux.org>
|
24
pkg/usr/share/man/man1/dirname.1
Normal file
24
pkg/usr/share/man/man1/dirname.1
Normal file
@ -0,0 +1,24 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH dirname 1 "dirname 0.1.0"
|
||||
.SH NAME
|
||||
dirname \- strip last component from file name
|
||||
.SH SYNOPSIS
|
||||
\fBdirname\fR [\fB\-z\fR|\fB\-\-zero\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIname\fR>
|
||||
.SH DESCRIPTION
|
||||
strip last component from file name
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-z\fR, \fB\-\-zero\fR
|
||||
end each output line with NUL, not newline
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.TP
|
||||
<\fIname\fR>
|
||||
|
||||
.SH VERSION
|
||||
v0.1.0
|
26
pkg/usr/share/man/man1/echo.1
Normal file
26
pkg/usr/share/man/man1/echo.1
Normal file
@ -0,0 +1,26 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH echo 1 "echo 0.1.0"
|
||||
.SH NAME
|
||||
echo \- Display a line of text
|
||||
.SH SYNOPSIS
|
||||
\fBecho\fR [\fB\-n \fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fISTRING\fR]
|
||||
.SH DESCRIPTION
|
||||
Echo the STRING(s) to standard output
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-n\fR
|
||||
Do not output a trailing newline
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information (use `\-h` for a summary)
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.TP
|
||||
[\fISTRING\fR]
|
||||
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
Nathan Fisher
|
20
pkg/usr/share/man/man1/false.1
Normal file
20
pkg/usr/share/man/man1/false.1
Normal file
@ -0,0 +1,20 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH false 1 "false 0.1.0"
|
||||
.SH NAME
|
||||
false \- Does nothing unsuccessfully
|
||||
.SH SYNOPSIS
|
||||
\fBfalse\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR]
|
||||
.SH DESCRIPTION
|
||||
Exit with a status code indicating failure
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information (use `\-h` for a summary)
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
Nathan Fisher
|
38
pkg/usr/share/man/man1/head.1
Normal file
38
pkg/usr/share/man/man1/head.1
Normal file
@ -0,0 +1,38 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH head 1 "head 0.1.0"
|
||||
.SH NAME
|
||||
head \- Display first lines of a file
|
||||
.SH SYNOPSIS
|
||||
\fBhead\fR [\fB\-c\fR|\fB\-\-bytes\fR] [\fB\-q\fR|\fB\-\-quiet\fR] [\fB\-v\fR|\fB\-\-verbose\fR] [\fB\-n\fR|\fB\-\-lines\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIFILES\fR]
|
||||
.SH DESCRIPTION
|
||||
Print the first 10 lines of each FILE to standard output.
|
||||
With more than one FILE, precede each with a header giving the file name.
|
||||
.PP
|
||||
With no FILE, or when FILE is \-, read standard input.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-c\fR, \fB\-\-bytes\fR
|
||||
Count bytes instead of lines
|
||||
.TP
|
||||
\fB\-q\fR, \fB\-\-quiet\fR
|
||||
Disable printing a header. Overrides \-c
|
||||
.TP
|
||||
\fB\-v\fR, \fB\-\-verbose\fR
|
||||
Each file is preceded by a header consisting of the string "==> XXX <==" where "XXX" is the name of the file.
|
||||
.TP
|
||||
\fB\-n\fR, \fB\-\-lines\fR
|
||||
Count n number of lines (or bytes if \-c is specified).
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information (use `\-h` for a summary)
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.TP
|
||||
[\fIFILES\fR]
|
||||
The input file to use
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
Nathan Fisher
|
26
pkg/usr/share/man/man1/hostname.1
Normal file
26
pkg/usr/share/man/man1/hostname.1
Normal file
@ -0,0 +1,26 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH hostname 1 "hostname 0.1.0"
|
||||
.SH NAME
|
||||
hostname \- Prints the name of the current host. The super\-user can set the host name by supplying an argument.
|
||||
.SH SYNOPSIS
|
||||
\fBhostname\fR [\fB\-s\fR|\fB\-\-strip\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fINAME\fR]
|
||||
.SH DESCRIPTION
|
||||
Prints the name of the current host. The super\-user can set the host name by supplying an argument.
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-strip\fR
|
||||
Removes any domain information from the printed name.
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.TP
|
||||
[\fINAME\fR]
|
||||
name to set
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
The JeanG3nie <jeang3nie@hitchhiker\-linux.org>
|
20
pkg/usr/share/man/man1/nologin.1
Normal file
20
pkg/usr/share/man/man1/nologin.1
Normal file
@ -0,0 +1,20 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH nologin 1 "nologin 0.1.0"
|
||||
.SH NAME
|
||||
nologin \- Denies a user account login ability
|
||||
.SH SYNOPSIS
|
||||
\fBnologin\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR]
|
||||
.SH DESCRIPTION
|
||||
Denies a user account login ability
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
Nathan Fisher
|
46
pkg/usr/share/man/man1/shitbox-bootstrap.1
Normal file
46
pkg/usr/share/man/man1/shitbox-bootstrap.1
Normal file
@ -0,0 +1,46 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH bootstrap 1 "bootstrap 0.1.0"
|
||||
.SH NAME
|
||||
bootstrap \- Install shitbox into the filesystem
|
||||
.SH SYNOPSIS
|
||||
\fBbootstrap\fR [\fB\-p\fR|\fB\-\-prefix\fR] [\fB\-u\fR|\fB\-\-usr\fR] [\fB\-s\fR|\fB\-\-soft\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
Install symlinks, manpages and shell completions
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-p\fR, \fB\-\-prefix\fR [default: /]
|
||||
The directory path under which to install
|
||||
.TP
|
||||
\fB\-u\fR, \fB\-\-usr\fR
|
||||
Split the installation so that some applets go into /bin | /sbin
|
||||
while others are placed into /usr/bin | /usr/sbin
|
||||
.TP
|
||||
\fB\-s\fR, \fB\-\-soft\fR
|
||||
Install soft links instead of hardlinks
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information (use `\-h` for a summary)
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
bootstrap\-all(1)
|
||||
Install everything
|
||||
.TP
|
||||
bootstrap\-links(1)
|
||||
Install links for each applet
|
||||
.TP
|
||||
bootstrap\-manpages(1)
|
||||
Install Unix man pages
|
||||
.TP
|
||||
bootstrap\-completions(1)
|
||||
Install shell completions
|
||||
.TP
|
||||
bootstrap\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
Nathan Fisher
|
52
pkg/usr/share/man/man1/shitbox.1
Normal file
52
pkg/usr/share/man/man1/shitbox.1
Normal file
@ -0,0 +1,52 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH shitbox 1 "shitbox 0.1.0"
|
||||
.SH NAME
|
||||
shitbox \- The Harbor Freight multitool of embedded Linux
|
||||
.SH SYNOPSIS
|
||||
\fBshitbox\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] [\fIsubcommands\fR]
|
||||
.SH DESCRIPTION
|
||||
The Harbor Freight multitool of embedded Linux
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.SH SUBCOMMANDS
|
||||
.TP
|
||||
shitbox\-base32(1)
|
||||
Base32 encode/decode data and print to standard output
|
||||
.TP
|
||||
shitbox\-bootstrap(1)
|
||||
Install shitbox into the filesystem
|
||||
.TP
|
||||
shitbox\-echo(1)
|
||||
Display a line of text
|
||||
.TP
|
||||
shitbox\-dirname(1)
|
||||
strip last component from file name
|
||||
.TP
|
||||
shitbox\-false(1)
|
||||
Does nothing unsuccessfully
|
||||
.TP
|
||||
shitbox\-head(1)
|
||||
Display first lines of a file
|
||||
.TP
|
||||
shitbox\-nologin(1)
|
||||
Denies a user account login ability
|
||||
.TP
|
||||
shitbox\-hostname(1)
|
||||
Prints the name of the current host. The super\-user can set the host name by supplying an argument.
|
||||
.TP
|
||||
shitbox\-sleep(1)
|
||||
Suspend execution for an interval of time
|
||||
.TP
|
||||
shitbox\-true(1)
|
||||
Does nothing successfully
|
||||
.TP
|
||||
shitbox\-help(1)
|
||||
Print this message or the help of the given subcommand(s)
|
||||
.SH VERSION
|
||||
v0.1.0
|
25
pkg/usr/share/man/man1/sleep.1
Normal file
25
pkg/usr/share/man/man1/sleep.1
Normal file
@ -0,0 +1,25 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH sleep 1 "sleep 0.1.0"
|
||||
.SH NAME
|
||||
sleep \- Suspend execution for an interval of time
|
||||
.SH SYNOPSIS
|
||||
\fBsleep\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] <\fIseconds\fR>
|
||||
.SH DESCRIPTION
|
||||
The sleep utility suspends execution for a minimum of the specified number of seconds.
|
||||
This number must be positive and may contain a decimal fraction.
|
||||
sleep is commonly used to schedule the execution of other commands
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information (use `\-h` for a summary)
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.TP
|
||||
<\fIseconds\fR>
|
||||
The number of seconds to sleep
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
|
20
pkg/usr/share/man/man1/true.1
Normal file
20
pkg/usr/share/man/man1/true.1
Normal file
@ -0,0 +1,20 @@
|
||||
.ie \n(.g .ds Aq \(aq
|
||||
.el .ds Aq '
|
||||
.TH true 1 "true 0.1.0"
|
||||
.SH NAME
|
||||
true \- Does nothing successfully
|
||||
.SH SYNOPSIS
|
||||
\fBtrue\fR [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR]
|
||||
.SH DESCRIPTION
|
||||
Exit with a status code indicating success
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
\fB\-h\fR, \fB\-\-help\fR
|
||||
Print help information (use `\-h` for a summary)
|
||||
.TP
|
||||
\fB\-V\fR, \fB\-\-version\fR
|
||||
Print version information
|
||||
.SH VERSION
|
||||
v0.1.0
|
||||
.SH AUTHORS
|
||||
Nathan Fisher
|
@ -1,5 +1,5 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use clap::{Arg, ArgAction, Command, value_parser};
|
||||
use data_encoding::BASE32;
|
||||
use std::{
|
||||
fs,
|
||||
@ -25,7 +25,6 @@ impl Cmd for Base32 {
|
||||
|
||||
fn cli(&self) -> clap::Command {
|
||||
Command::new("base32")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("The JeanG3nie <jeang3nie@hitchhiker-linux.org>")
|
||||
.about("Base32 encode/decode data and print to standard output")
|
||||
.args([
|
||||
@ -46,6 +45,7 @@ impl Cmd for Base32 {
|
||||
.help("Wrap encoded lines after n characters")
|
||||
.short('w')
|
||||
.long("wrap")
|
||||
.value_parser(value_parser!(usize))
|
||||
.default_value("76"),
|
||||
Arg::new("VERBOSE")
|
||||
.help("Display a header naming each file")
|
||||
|
63
src/cmd/dirname/mod.rs
Normal file
63
src/cmd/dirname/mod.rs
Normal file
@ -0,0 +1,63 @@
|
||||
use super::Cmd;
|
||||
use clap::{Arg, ArgAction, Command};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Dirname {
|
||||
name: &'static str,
|
||||
path: Option<crate::Path>,
|
||||
}
|
||||
|
||||
pub const DIRNAME: Dirname = Dirname {
|
||||
name: "dirname",
|
||||
path: Some(crate::Path::UsrBin),
|
||||
};
|
||||
|
||||
impl Cmd for Dirname {
|
||||
fn name(&self) -> &str {
|
||||
self.name
|
||||
}
|
||||
|
||||
fn cli(&self) -> clap::Command {
|
||||
Command::new("dirname")
|
||||
.about("strip last component from file name")
|
||||
.args([
|
||||
Arg::new("zero")
|
||||
.short('z')
|
||||
.long("zero")
|
||||
.help("end each output line with NUL, not newline")
|
||||
.action(ArgAction::SetTrue),
|
||||
Arg::new("name").num_args(1..).required(true),
|
||||
])
|
||||
}
|
||||
|
||||
fn run(&self, matches: Option<&clap::ArgMatches>) -> Result<(), Box<dyn std::error::Error>> {
|
||||
if let Some(matches) = matches {
|
||||
if let Some(names) = matches.get_many::<String>("name") {
|
||||
names.for_each(|name| {
|
||||
let path = match Path::new(name).parent() {
|
||||
Some(p) => p,
|
||||
None => Path::new("."),
|
||||
};
|
||||
let path = path.to_string_lossy();
|
||||
let path = if path.is_empty() {
|
||||
String::from(".")
|
||||
} else {
|
||||
path.to_string()
|
||||
};
|
||||
if matches.get_flag("zero") {
|
||||
print!("{}\0", path);
|
||||
} else {
|
||||
println!("{}", path);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn path(&self) -> Option<crate::Path> {
|
||||
self.path
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ impl Cmd for Echo {
|
||||
Command::new(self.name)
|
||||
.about("Display a line of text")
|
||||
.long_about("Echo the STRING(s) to standard output")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("Nathan Fisher")
|
||||
.args([
|
||||
Arg::new("inline")
|
||||
|
@ -24,7 +24,6 @@ impl Cmd for False {
|
||||
.about("Does nothing unsuccessfully")
|
||||
.long_about("Exit with a status code indicating failure")
|
||||
.author("Nathan Fisher")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
}
|
||||
|
||||
fn run(&self, _matches: Option<&clap::ArgMatches>) -> Result<(), Box<dyn Error>> {
|
||||
|
@ -2,10 +2,11 @@ use super::Cmd;
|
||||
use crate::Path;
|
||||
use clap::{value_parser, Arg, ArgAction, ArgMatches, Command};
|
||||
use std::{
|
||||
env,
|
||||
error::Error,
|
||||
fs,
|
||||
io::{self, stdin, Read},
|
||||
process, env,
|
||||
process,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
@ -26,7 +27,6 @@ impl Cmd for Head {
|
||||
|
||||
fn cli(&self) -> Command {
|
||||
Command::new(self.name)
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("Nathan Fisher")
|
||||
.about("Display first lines of a file")
|
||||
.long_about(
|
||||
@ -85,12 +85,7 @@ impl Cmd for Head {
|
||||
vec!["-"]
|
||||
};
|
||||
for file in &files {
|
||||
head(
|
||||
&file,
|
||||
lines,
|
||||
false,
|
||||
false,
|
||||
);
|
||||
head(&file, lines, false, false);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
@ -113,12 +108,7 @@ impl Cmd for Head {
|
||||
if index == 1 && header {
|
||||
println!();
|
||||
}
|
||||
head(
|
||||
&file,
|
||||
lines,
|
||||
header,
|
||||
matches.get_flag("BYTES"),
|
||||
);
|
||||
head(&file, lines, header, matches.get_flag("BYTES"));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -21,7 +21,6 @@ impl Cmd for Hostname {
|
||||
|
||||
fn cli(&self) -> clap::Command {
|
||||
Command::new(self.name)
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("The JeanG3nie <jeang3nie@hitchhiker-linux.org>")
|
||||
.about("Prints the name of the current host. The super-user can set the host name by supplying an argument.")
|
||||
.args([
|
||||
|
@ -16,6 +16,7 @@ mod chmod;
|
||||
mod cp;
|
||||
mod date;
|
||||
mod dd;
|
||||
pub mod dirname;
|
||||
pub mod echo;
|
||||
pub mod r#false;
|
||||
mod getty;
|
||||
@ -38,6 +39,7 @@ pub use {
|
||||
self::hostname::{Hostname, HOSTNAME},
|
||||
base32::{Base32, BASE_32},
|
||||
bootstrap::{Bootstrap, BOOTSTRAP},
|
||||
dirname::{Dirname, DIRNAME},
|
||||
echo::{Echo, ECHO},
|
||||
head::{Head, HEAD},
|
||||
nologin::{Nologin, NOLOGIN},
|
||||
|
@ -20,7 +20,6 @@ impl Cmd for Nologin {
|
||||
|
||||
fn cli(&self) -> clap::Command {
|
||||
Command::new(self.name)
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("Nathan Fisher")
|
||||
.about("Denies a user account login ability")
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
use super::{Cmd, BOOTSTRAP, ECHO, FALSE, HEAD, HOSTNAME, NOLOGIN, SLEEP, TRUE, BASE_32};
|
||||
use super::{Cmd, BASE_32, BOOTSTRAP, DIRNAME, ECHO, FALSE, HEAD, HOSTNAME, NOLOGIN, SLEEP, TRUE};
|
||||
use clap::Command;
|
||||
use std::{
|
||||
error::Error,
|
||||
@ -25,10 +25,14 @@ impl Cmd for Shitbox {
|
||||
Command::new(self.name)
|
||||
.about("The Harbor Freight multitool of embedded Linux")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.propagate_version(true)
|
||||
.arg_required_else_help(true)
|
||||
.subcommand_value_name("APPLET")
|
||||
.subcommand_help_heading("APPLETS")
|
||||
.subcommands([
|
||||
BASE_32.cli(),
|
||||
BOOTSTRAP.cli(),
|
||||
DIRNAME.cli(),
|
||||
ECHO.cli(),
|
||||
FALSE.cli(),
|
||||
HEAD.cli(),
|
||||
@ -48,6 +52,7 @@ impl Cmd for Shitbox {
|
||||
match matches.subcommand() {
|
||||
Some(("base32", matches)) => BASE_32.run(Some(matches))?,
|
||||
Some(("bootstrap", matches)) => BOOTSTRAP.run(Some(matches))?,
|
||||
Some(("dirname", matches)) => DIRNAME.run(Some(matches))?,
|
||||
Some(("echo", _matches)) => ECHO.run(None)?,
|
||||
Some(("false", _matches)) => FALSE.run(None)?,
|
||||
Some(("head", matches)) => HEAD.run(Some(matches))?,
|
||||
|
@ -27,7 +27,6 @@ impl Cmd for Sleep {
|
||||
This number must be positive and may contain a decimal fraction.\n\
|
||||
sleep is commonly used to schedule the execution of other commands"
|
||||
)
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author(env!("CARGO_PKG_AUTHORS"))
|
||||
.arg(
|
||||
Arg::new("seconds")
|
||||
|
@ -23,7 +23,6 @@ impl Cmd for True {
|
||||
Command::new(self.name)
|
||||
.about("Does nothing successfully")
|
||||
.long_about("Exit with a status code indicating success")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.author("Nathan Fisher")
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,9 @@
|
||||
use std::{env, error::Error, path::PathBuf, string::ToString};
|
||||
|
||||
pub mod cmd;
|
||||
use cmd::{Cmd, Commands, BOOTSTRAP, ECHO, FALSE, HEAD, HOSTNAME, NOLOGIN, SHITBOX, SLEEP, TRUE, BASE_32};
|
||||
use cmd::{
|
||||
Cmd, Commands, BASE_32, BOOTSTRAP, DIRNAME, ECHO, FALSE, HEAD, HOSTNAME, NOLOGIN, SHITBOX, SLEEP, TRUE,
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum Path {
|
||||
@ -37,7 +39,8 @@ pub fn run() -> Result<(), Box<dyn Error>> {
|
||||
cmd::COMMANDS
|
||||
.set(Commands {
|
||||
items: vec![
|
||||
&BASE_32, &BOOTSTRAP, &ECHO, &FALSE, &HEAD, &HOSTNAME, &NOLOGIN, &TRUE, &SLEEP, &SHITBOX,
|
||||
&BASE_32, &BOOTSTRAP, &DIRNAME, &ECHO, &FALSE, &HEAD, &HOSTNAME, &NOLOGIN, &TRUE, &SLEEP,
|
||||
&SHITBOX,
|
||||
],
|
||||
})
|
||||
.expect("Cannot register commands");
|
||||
@ -45,6 +48,7 @@ pub fn run() -> Result<(), Box<dyn Error>> {
|
||||
if let Some(progname) = progname() {
|
||||
match progname.as_str() {
|
||||
"base32" => BASE_32.run(Some(&BASE_32.cli().get_matches()))?,
|
||||
"dirname" => DIRNAME.run(Some(&DIRNAME.cli().get_matches()))?,
|
||||
"echo" => ECHO.run(None)?,
|
||||
"false" => FALSE.run(None)?,
|
||||
"head" => {
|
||||
|
Loading…
Reference in New Issue
Block a user