termonad
termonad copied to clipboard
take arguments on the command line
It would be nice to accept arguments to termonad
on the command line. Where possible, the current Termonad options should be able to be specified on the command line as flags:
http://hackage.haskell.org/package/termonad-1.0.0.0/docs/Termonad-Config.html
However, not all options will be able to be easily specified on the command line. That's okay. You'll also need to make sure that options specified on the command line override those specified in the Termonad configuration file (termonad.hs
).
You'll have to make the command line option parser extensible by Termonad extensions. Currently the only extension is the color extension:
http://hackage.haskell.org/package/termonad-1.0.0.0/docs/Termonad-Config-Colour.html
Since termonad
uses dyre
to recompile the configuration file, you'll have to figure out how command line flags interact with this process. Ideally something like the following would be possible:
- Run
termonad
with a bunch of different command line flags. -
termonad
parses the ones it understands, and ignores the ones it doesn't understand. -
termonad
looks for a special command line flag like--conf-file
that has the location of thetermonad.hs
configuration file. -
termonad
uses this new configuration file location to load the configuration and recompile. -
termonad
launches the newtermonad
binary, passing it ALL of the original command line flags. - The new
termonad
binary is able to use all the command line flags.
When implementing this, please use a common command line parser like optparse-applicative
.
As long as you've used optparse-applicative
, this shouldn't actually be too difficult to figure out. It is also a good way to get familiar with all of Termonad's options, since you'll have to make sure to parse them on the command line.
Although, this might be tricky to figure out how to make the parser extensible by extensions, as well as the interactions with dyre
. If you try to tackle this but end up needing help, please feel free to ask on this issue.
Hi there - I've started working on this.
I've noticed that dyre
will only allow you to specify a different directory for its config search. it expects the name of the file to match your executable i.e. termonad and termonad.hs. Do you think that's enough?
In my testing so far the new binary seems to receive and process the original flags as expected.
I haven't really looked at extensions yet. My first thought is that I should be able to write a parser in one of them and use its hook to process them there.
Hi, thanks for working on this!
I've noticed that dyre will only allow you to specify a different directory for its config search. it expects the name of the file to match your executable i.e. termonad and termonad.hs. Do you think that's enough?
Yeah, that sounds good for now. I guess eventually we should send a PR to dyre
to add an option to change the name of the configuration file, but that is out of scope for this issue.
In my testing so far the new binary seems to receive and process the original flags as expected.
Okay great, looking forward to the PR!
I haven't really looked at extensions yet. My first thought is that I should be able to write a parser in one of them and use its hook to process them there.
Yeah, maybe adding a new hook that is able to process the command line arguments would be the easiest thing to do here.
Although I really haven't thought about this too much recently, so there could be an easier way.
@aware70 Are you still working on this? If you don't mind, I'd like to help you with this issue.
@lattfein As far as I know, this is not being worked on, so please feel free to go ahead and start working on this.
On Debian systems, a terminal emulator that wants to provide the virtual package x-terminal-emulator must understand the -e and -T options: https://www.debian.org/doc/debian-policy/ch-customized-programs.html#packages-providing-a-terminal-emulator
BTW: I learned about termonad now because it entered the Debian archive.
@thkoch2001 Thanks for the heads up!
I'd be happy to take a PR adding support for -e
and -T
. From the linked webpage:
To be an x-terminal-emulator, a program must:
Be able to emulate a DEC VT100 terminal, or a compatible terminal.
Support the command-line option -e command, which creates a new terminal window 6 and runs the specified command.
may be multiple arguments, which form the argument list to the executed program. In other words, the behavior is as though the arguments were passed directly to execvp, bypassing the shell. (xterm’s behavior of falling back on using the shell if -e had a single argument and exec failed is permissible but not required.) Support the command-line option -T title, which creates a new terminal window with the window title title.
It would also be nice to have an option like --ignore-conf-file
that ignores the ~/.config/termonad/termonad.hs
and ~/.config/termonad/termonad.yaml
configuration files and just launches termonad with the default config.
+1
This is implemented in #234.
However, I didn't add an option for ignoring the config file as suggested in https://github.com/cdepillabout/termonad/issues/81#issuecomment-753733687. If someone wants this, I'd be happy to merge in a PR adding this.