Implement the command line parsing in chezroot to satisfy these requirements:
The purpose of chezroot is to call chezmoi via sudo when appropriate, passing its command line arguments directly to chezmoi (with some exceptions). Calling via sudo or non-sudo is based on the command given by the user on the command line.
-
chezroot will need to be able to determine the "command line items" given by the user: global flags, command, subcommand, and command specific options and flags, etc.
-
For most commands, chezroot will call chezmoi with all the arguments it received in a spawned subprocess. stdout, stderr, and the process status returned from chezmoi should be returned by chezroot
-
chezroot will need to add some global options to the chezmoi command line. For instance, --destination DIRECTORY and --source DIRECTORY.
-
Certain command line items will be disallowed by chezroot. In this case, chezroot will display an error instead of calling chezmoi. For instance, the --destination, --source, and --config global options are not allowed. And the --apply and --watch options to the edit command are not allowed.
-
Certain global flags that chezroot will need to filter out for itself and not pass to chezmoi. For instance, the global flag --profile=NAME will be removed from the command line passed on to chezmoi. chezroot will need to use the given NAME.
-
chezroot will need to intercept some commands to wrap their functionality (do something before and/or after the chezmoi command is called) or do something totally different without calling chezmoi at all
-
chezroot will add certain commands that it will implement and not pass on to chezmoi. An example of this is the profile management command as described in this repository's README.md
Implement the command line parsing in
chezrootto satisfy these requirements:The purpose of
chezrootis to callchezmoivia sudo when appropriate, passing its command line arguments directly tochezmoi(with some exceptions). Calling via sudo or non-sudo is based on the command given by the user on the command line.chezrootwill need to be able to determine the "command line items" given by the user: global flags, command, subcommand, and command specific options and flags, etc.For most commands,
chezrootwill callchezmoiwith all the arguments it received in a spawned subprocess. stdout, stderr, and the process status returned fromchezmoishould be returned bychezrootchezrootwill need to add some global options to thechezmoicommand line. For instance,--destination DIRECTORYand--source DIRECTORY.Certain command line items will be disallowed by
chezroot. In this case,chezrootwill display an error instead of callingchezmoi. For instance, the--destination,--source, and--configglobal options are not allowed. And the--applyand--watchoptions to theeditcommand are not allowed.Certain global flags that
chezrootwill need to filter out for itself and not pass tochezmoi. For instance, the global flag--profile=NAMEwill be removed from the command line passed on tochezmoi.chezrootwill need to use the given NAME.chezrootwill need to intercept some commands to wrap their functionality (do something before and/or after thechezmoicommand is called) or do something totally different without callingchezmoiat allchezrootwill add certain commands that it will implement and not pass on tochezmoi. An example of this is theprofilemanagement command as described in this repository's README.md