diff options
Diffstat (limited to 'main.ha')
| -rw-r--r-- | main.ha | 29 |
1 files changed, 23 insertions, 6 deletions
@@ -1,18 +1,35 @@ use fmt; use getopt; use os; +use fs; +use io; -use convert; use mbr; use gpt; +use convert; +use create; +use header; +use mkbackup; + export fn main() void = { - if (len(os::args) < 2) { - fmt::fatalf("{}: expected command", os::args[0]); + if (len(os::args) < 3) { + fmt::fatalf("{}: expected disk name", os::args[0]); + }; + + const volume = match(os::create(os::args[1], fs::mode::USER_RWX | fs::mode::GROUP_RX | fs::mode::OTHER_RX, fs::flags::RDWR)) { + case let v: io::file => + yield v; + case => + fmt::fatalf("{}: cannot open file {}", os::args[0], os::args[1]); }; + defer io::close(volume)!; - switch (os::args[1]) { - case "convert" => convert::convert(os::args[1..]); - case => fmt::fatalf("{}: no such command {}", os::args[0], os::args[1]); + switch (os::args[2]) { + case "convert" => convert::convert(volume, os::args[2..]); + case "create" => create::create(volume, os::args[2..]); + case "header" => header::header(volume, os::args[2..]); + case "mkbackup" => mkbackup::mkbackup(volume, os::args[2..]); + case => fmt::fatalf("{}: no such command {}", os::args[0], os::args[2]); }; }; |
