This commit changes the signal handler to be added once
the command is executing. this is because the daemon
has its own signal handler, that must try to shut down
the node gracefully first. You know, just in case.
This commit adds a Mount abstraction (which is really just
a wrapped context closer). It makes sure to bind the mount
to the fate of the Node (i.e. close it if the node ends).
This fixes#350
@jbenet @mappum
Yeah, there's some duplicated work. But there's also a separation of
concerns. In one case, we check to determine where the command should
run. In the other case, we check to determine which hooks should run.
Having these actions separated reduces complexity in a nice way.
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
impl errorf
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
return a debug error
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
not immediately useful, but nice to have
tagging you to make sure i didn't make a mistake here @jbenet
License: MIT
Signed-off-by: Brian Tiger Chow <brian@perfmode.com>
eg.
```
ipfs2 (cmd-ref-part2) λ. go build ./...; ./ipfs2 tour 0
Tour 0 - Hello Mars
Hello Mars
ipfs2 (cmd-ref-part2) λ. go build ./...; ./ipfs2 tour 10
ERROR
no topic with id: 10
TOPICS
0 - Hello Mars
0.1 - Hello Mars 2
```
This commit adds the pretty-complicated decision function
to check whether a command should run on the daemon.
@maybebtc @mappum double check the logic?
Attention @maybebtc @mappum
I cleaned up + simplified the main flow. Now, all printing
is contained inside main itself! (:cheer:). I do this with
the help of a cmdInvocation struct that has both
a Parse and Run. The only major clunkiness left is that the
"CallCommand" is still its own function. But *shrug*.
Please test it works as we would expect. i changed much of
the flow, so likely that i missed a complicated edge case.
main roadmap:
- parse the commandline to get a cmdInvocation
- if user requests, help, print it and exit.
- run the command invocation
- output the response
- if anything fails, print error, maybe with help