@@ 8,6 8,7 @@ use errors;
use fmt;
use format::ssh;
use fs;
+use getopt;
use himitsu::client;
use himitsu::query;
use himitsu::remember;
@@ 30,12 31,32 @@ type server = struct {
};
export fn main() void = {
- // TODO: Parse options (foreground/background, socket path)
- // TODO: Fork to background
- const path = path::init()!;
- path::set(&path, dirs::runtime()!, "hissh-agent")!;
+ const cmd = getopt::parse(os::args,
+ "hissh import",
+ ('a', "address", "bind to the unix-domain socket address"),
+ );
+ defer getopt::finish(&cmd);
+
+ let address: (str | void) = void;
+ for (let i = 0z; i < len(cmd.opts); i += 1) {
+ const opt = cmd.opts[i];
+ switch (opt.0) {
+ case 'a' =>
+ address = strings::dup(opt.1);
+ case =>
+ fmt::fatalf("unknown option");
+ };
+ };
+
+ const sockpath = match (address) {
+ case let s: str =>
+ yield s;
+ case void =>
+ const path = path::init()!;
+ path::set(&path, dirs::runtime()!, "hissh-agent")!;
+ yield path::string(&path);
+ };
- const sockpath = path::string(&path);
const socket = match (unix::listen(sockpath)) {
case let sock: net::socket =>
yield sock;