Skip to content

Commit e362e5c

Browse files
committed
nix-script-haskell: nits
1 parent ca7911f commit e362e5c

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

nix-script-haskell/src/main.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,16 @@ struct Opts {
4545
#[clap(long, default_value("nix-script"), hide(true))]
4646
nix_script_bin: PathBuf,
4747

48-
/// The script and args to pass to nix-script
48+
/// The script and arguments to pass to nix-script
4949
#[arg(num_args = 1.., required = true)]
50-
script_and_args: Vec<String>,
50+
script_and_arguments: Vec<String>,
5151
}
5252

5353
impl Opts {
5454
fn run(&self) -> Result<ExitStatus> {
5555
let (script, args) = self
56-
.parse_script_and_args()
57-
.context("could not parse script and args")?;
56+
.get_script_and_arguments()
57+
.context("could not get script and arguments")?;
5858

5959
let directives = Directives::from_file("#!", &script)
6060
.context("could not parse directives from script")?;
@@ -109,13 +109,16 @@ impl Opts {
109109
child.wait().context("could not run the script")
110110
}
111111

112-
fn parse_script_and_args(&self) -> Result<(PathBuf, Vec<String>)> {
112+
fn get_script_and_arguments(&self) -> Result<(PathBuf, Vec<String>)> {
113113
log::trace!("parsing script and args");
114-
let mut script_and_args = self.script_and_args.iter();
115114

116-
let script = PathBuf::from(script_and_args.next().context("I need at least a script name to run, but didn't get one. This represents an internal error, and you should open a bug!")?);
115+
let script = PathBuf::from(
116+
self.script_and_arguments
117+
.first()
118+
.context("no script to run; this is a bug; please report")?,
119+
);
117120

118-
Ok((script, self.script_and_args[1..].to_vec()))
121+
Ok((script, self.script_and_arguments[1..].to_vec()))
119122
}
120123
}
121124

@@ -128,7 +131,7 @@ fn main() {
128131
match opts.run().map(|status| status.code()) {
129132
Ok(Some(code)) => std::process::exit(code),
130133
Ok(None) => {
131-
log::warn!("we didn't receive an exit code; was the script killed with a signal?");
134+
log::warn!("no exit code; was the script killed with a signal?");
132135
std::process::exit(1)
133136
}
134137
Err(err) => {

0 commit comments

Comments
 (0)