Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(request): defaults the format value to the output file extension if present #37

Merged
merged 1 commit into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feat(request): default format value to file extension
  • Loading branch information
jmgilman committed Jun 20, 2022
commit cc612317db087cdb86784fbf03b078c3f7a6e818
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ in
nixago.lib.make {
inherit configData;
output = "config.json";
format = "json";
engine = nixago.engines.nix { }; # Optional as this is the default value
format = "json"; # Optional if it matches the file extension
engine = nixago.engines.nix { }; # Optional as this is the default engine
}
```

Expand Down
8 changes: 7 additions & 1 deletion modules/request.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This module holds the main data structure that's used when handling a
"request" from the user to generate a configuration file.
*/
{ lib, engines, ... }:
{ lib, config, engines, ... }:
with lib;
let
hook = types.submodule ({ config, lib, ... }:
Expand Down Expand Up @@ -38,6 +38,12 @@ in
format = mkOption {
type = types.str;
description = "The format of the output file";
default = (
let
parts = splitString "." config.output;
in
builtins.elemAt parts ((builtins.length parts) - 1)
);
};
hook = mkOption {
type = hook;
Expand Down