eh: add develop alias nd; prompt before auto-fixing hashes
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I74835b683e247c86e4907d4fe0eccba06a6a6964
This commit is contained in:
parent
ab35745f53
commit
7f9364eb88
3 changed files with 25 additions and 1 deletions
|
|
@ -31,6 +31,11 @@ pub enum Command {
|
|||
#[arg(trailing_var_arg = true)]
|
||||
args: Vec<String>,
|
||||
},
|
||||
/// Enter a Nix development shell
|
||||
Develop {
|
||||
#[arg(trailing_var_arg = true)]
|
||||
args: Vec<String>,
|
||||
},
|
||||
/// Update flake inputs interactively
|
||||
Update {
|
||||
#[arg(trailing_var_arg = true)]
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ fn handle_command(command: &str, args: &[String]) -> error::Result<i32> {
|
|||
|
||||
match command {
|
||||
"update" => commands::update::handle_update(args),
|
||||
"run" | "shell" | "build" => {
|
||||
"run" | "shell" | "build" | "develop" => {
|
||||
commands::handle_nix_command(
|
||||
command,
|
||||
args,
|
||||
|
|
@ -55,6 +55,7 @@ fn dispatch_multicall(
|
|||
"nr" => "run",
|
||||
"ns" => "shell",
|
||||
"nb" => "build",
|
||||
"nd" => "develop",
|
||||
"nu" => "update",
|
||||
_ => return None,
|
||||
};
|
||||
|
|
@ -104,6 +105,8 @@ fn run_app() -> error::Result<i32> {
|
|||
|
||||
Some(Command::Build { args }) => handle_command("build", &args),
|
||||
|
||||
Some(Command::Develop { args }) => handle_command("develop", &args),
|
||||
|
||||
Some(Command::Update { args }) => handle_command("update", &args),
|
||||
|
||||
None => {
|
||||
|
|
|
|||
|
|
@ -511,6 +511,22 @@ pub fn handle_nix_with_retry(
|
|||
// Check for hash mismatch errors
|
||||
if let Some(new_hash) = hash_extractor.extract_hash(&stderr) {
|
||||
let old_hash = hash_extractor.extract_old_hash(&stderr);
|
||||
|
||||
// Ask for confirmation before fixing hash
|
||||
let should_fix = dialoguer::Confirm::new()
|
||||
.with_prompt(format!(
|
||||
"Hash mismatch detected for {}. Update hash in local .nix files?",
|
||||
pkg.bold()
|
||||
))
|
||||
.default(true)
|
||||
.interact()
|
||||
.map_err(|e| EhError::Io(std::io::Error::other(e)))?;
|
||||
|
||||
if !should_fix {
|
||||
log_warn!("{}: hash fix cancelled by user", pkg.bold());
|
||||
return Err(EhError::ProcessExit { code: 1 });
|
||||
}
|
||||
|
||||
match fixer.fix_hash_in_files(old_hash.as_deref(), &new_hash) {
|
||||
Ok(true) => {
|
||||
log_info!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue