1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-01 04:18:00 +02:00

nix: Add command baseDir to parse --expr relative to shebang script

This commit is contained in:
Robert Hensing 2023-05-12 19:54:54 +02:00 committed by tomberek
parent 20ff61ab25
commit 198bc22e3b
5 changed files with 51 additions and 1 deletions

View file

@ -24,6 +24,16 @@ class AddCompletions;
class Args
{
/**
* @brief The command's "working directory", but only set when top level.
*
* Use getCommandBaseDir() to get the directory regardless of whether this
* is a top-level command or subcommand.
*
* @see getCommandBaseDir()
*/
Path commandBaseDir = ".";
public:
/**
@ -44,6 +54,16 @@ public:
*/
virtual std::string doc() { return ""; }
/**
* @brief Get the base directory for the command.
*
* @return Generally the working directory, but in case of a shebang
* interpreter, returns the directory of the script.
*
* This only returns the correct value after parseCmdline() has run.
*/
Path getCommandBaseDir() const;
protected:
/**