mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Merge pull request #8083 from edolstra/fix-nix-store-rendering
Fix misrendering of 'nix store --help'
This commit is contained in:
commit
cdfa59daa1
2 changed files with 13 additions and 3 deletions
|
@ -7,6 +7,7 @@ let
|
||||||
|
|
||||||
showCommand = { command, details, filename, toplevel }:
|
showCommand = { command, details, filename, toplevel }:
|
||||||
let
|
let
|
||||||
|
|
||||||
result = ''
|
result = ''
|
||||||
> **Warning** \
|
> **Warning** \
|
||||||
> This program is **experimental** and its interface is subject to change.
|
> This program is **experimental** and its interface is subject to change.
|
||||||
|
@ -25,6 +26,7 @@ let
|
||||||
|
|
||||||
${maybeOptions}
|
${maybeOptions}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
showSynopsis = command: args:
|
showSynopsis = command: args:
|
||||||
let
|
let
|
||||||
showArgument = arg: "*${arg.label}*" + (if arg ? arity then "" else "...");
|
showArgument = arg: "*${arg.label}*" + (if arg ? arity then "" else "...");
|
||||||
|
@ -32,6 +34,7 @@ let
|
||||||
in ''
|
in ''
|
||||||
`${command}` [*option*...] ${arguments}
|
`${command}` [*option*...] ${arguments}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
maybeSubcommands = if details ? commands && details.commands != {}
|
maybeSubcommands = if details ? commands && details.commands != {}
|
||||||
then ''
|
then ''
|
||||||
where *subcommand* is one of the following:
|
where *subcommand* is one of the following:
|
||||||
|
@ -39,26 +42,35 @@ let
|
||||||
${subcommands}
|
${subcommands}
|
||||||
''
|
''
|
||||||
else "";
|
else "";
|
||||||
|
|
||||||
subcommands = if length categories > 1
|
subcommands = if length categories > 1
|
||||||
then listCategories
|
then listCategories
|
||||||
else listSubcommands details.commands;
|
else listSubcommands details.commands;
|
||||||
|
|
||||||
categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues details.commands)));
|
categories = sort (x: y: x.id < y.id) (unique (map (cmd: cmd.category) (attrValues details.commands)));
|
||||||
|
|
||||||
listCategories = concatStrings (map showCategory categories);
|
listCategories = concatStrings (map showCategory categories);
|
||||||
|
|
||||||
showCategory = cat: ''
|
showCategory = cat: ''
|
||||||
**${toString cat.description}:**
|
**${toString cat.description}:**
|
||||||
|
|
||||||
${listSubcommands (filterAttrs (n: v: v.category == cat) details.commands)}
|
${listSubcommands (filterAttrs (n: v: v.category == cat) details.commands)}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
listSubcommands = cmds: concatStrings (attrValues (mapAttrs showSubcommand cmds));
|
listSubcommands = cmds: concatStrings (attrValues (mapAttrs showSubcommand cmds));
|
||||||
|
|
||||||
showSubcommand = name: subcmd: ''
|
showSubcommand = name: subcmd: ''
|
||||||
* [`${command} ${name}`](./${appendName filename name}.md) - ${subcmd.description}
|
* [`${command} ${name}`](./${appendName filename name}.md) - ${subcmd.description}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
maybeDocumentation = if details ? doc then details.doc else "";
|
maybeDocumentation = if details ? doc then details.doc else "";
|
||||||
|
|
||||||
maybeOptions = if details.flags == {} then "" else ''
|
maybeOptions = if details.flags == {} then "" else ''
|
||||||
# Options
|
# Options
|
||||||
|
|
||||||
${showOptions details.flags toplevel.flags}
|
${showOptions details.flags toplevel.flags}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
showOptions = options: commonOptions:
|
showOptions = options: commonOptions:
|
||||||
let
|
let
|
||||||
allOptions = options // commonOptions;
|
allOptions = options // commonOptions;
|
||||||
|
@ -99,7 +111,7 @@ let
|
||||||
in [ cmd ] ++ concatMap subcommand (attrNames details.commands or {});
|
in [ cmd ] ++ concatMap subcommand (attrNames details.commands or {});
|
||||||
|
|
||||||
parsedToplevel = builtins.fromJSON toplevel;
|
parsedToplevel = builtins.fromJSON toplevel;
|
||||||
|
|
||||||
manpages = processCommand {
|
manpages = processCommand {
|
||||||
command = "nix";
|
command = "nix";
|
||||||
details = parsedToplevel;
|
details = parsedToplevel;
|
||||||
|
|
|
@ -24,8 +24,6 @@ struct CmdCopyLog : virtual CopyCommand, virtual InstallablesCommand
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
Category category() override { return catUtility; }
|
|
||||||
|
|
||||||
void run(ref<Store> srcStore, Installables && installables) override
|
void run(ref<Store> srcStore, Installables && installables) override
|
||||||
{
|
{
|
||||||
auto & srcLogStore = require<LogStore>(*srcStore);
|
auto & srcLogStore = require<LogStore>(*srcStore);
|
||||||
|
|
Loading…
Reference in a new issue