mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 14:06:16 +02:00
Merge pull request #6103 from Radvendii/welcomeText
add descriptive output when creating templates
This commit is contained in:
commit
a768e85e2f
2 changed files with 21 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 markdown 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,16 @@ outputs = { self }: {
|
||||||
templates.rust = {
|
templates.rust = {
|
||||||
path = ./rust;
|
path = ./rust;
|
||||||
description = "A simple Rust/Cargo project";
|
description = "A simple Rust/Cargo project";
|
||||||
|
welcomeText = ''
|
||||||
|
# Simple Rust/Cargo Template
|
||||||
|
## Intended usage
|
||||||
|
The intended usage of this flake is...
|
||||||
|
|
||||||
|
## More info
|
||||||
|
- [Rust language](https://www.rust-lang.org/)
|
||||||
|
- [Rust on the NixOS Wiki](https://nixos.wiki/wiki/Rust)
|
||||||
|
- ...
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
templates.defaultTemplate = self.templates.rust;
|
templates.defaultTemplate = self.templates.rust;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "registry.hh"
|
#include "registry.hh"
|
||||||
#include "json.hh"
|
#include "json.hh"
|
||||||
#include "eval-cache.hh"
|
#include "eval-cache.hh"
|
||||||
|
#include "markdown.hh"
|
||||||
|
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
@ -731,6 +732,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);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -741,6 +743,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");
|
||||||
|
notice(renderMarkdownToTerminal(welcomeText->getString()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue