mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 17:16:15 +02:00
add descriptive output when creating templates
this includes a `welcomeText` attribute which can be set in the template, as well as outputing which files were created.
This commit is contained in:
parent
5b809f9e0e
commit
f3a2940e70
2 changed files with 14 additions and 0 deletions
|
@ -37,6 +37,10 @@ A flake can declare templates through its `templates` and
|
||||||
|
|
||||||
* `path`: The path of the directory to be copied.
|
* `path`: The path of the directory to be copied.
|
||||||
|
|
||||||
|
* `welcomeText`: A block of text to display when a user initializes a new flake
|
||||||
|
based on this template.
|
||||||
|
|
||||||
|
|
||||||
Here is an example:
|
Here is an example:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -45,6 +49,10 @@ outputs = { self }: {
|
||||||
templates.rust = {
|
templates.rust = {
|
||||||
path = ./rust;
|
path = ./rust;
|
||||||
description = "A simple Rust/Cargo project";
|
description = "A simple Rust/Cargo project";
|
||||||
|
welcomeText = ''
|
||||||
|
You've created a simple Rust/Cargo template.
|
||||||
|
Visit https://www.rust-lang.org/ for more info.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
templates.defaultTemplate = self.templates.rust;
|
templates.defaultTemplate = self.templates.rust;
|
||||||
|
|
|
@ -728,6 +728,7 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
else
|
else
|
||||||
throw Error("file '%s' has unsupported type", from2);
|
throw Error("file '%s' has unsupported type", from2);
|
||||||
files.push_back(to2);
|
files.push_back(to2);
|
||||||
|
notice("wrote: %s", to2);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -738,6 +739,11 @@ struct CmdFlakeInitCommon : virtual Args, EvalCommand
|
||||||
for (auto & s : files) args.push_back(s);
|
for (auto & s : files) args.push_back(s);
|
||||||
runProgram("git", true, args);
|
runProgram("git", true, args);
|
||||||
}
|
}
|
||||||
|
auto welcomeText = cursor->maybeGetAttr("welcomeText");
|
||||||
|
if (welcomeText) {
|
||||||
|
notice("\n----------\n");
|
||||||
|
notice(welcomeText->getString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue