diff options
| author | Alejandro Sior <aho@sior.be> | 2022-06-18 13:54:25 +0200 |
|---|---|---|
| committer | Alejandro Sior <aho@sior.be> | 2022-06-18 13:54:25 +0200 |
| commit | 6117a803ad717fd50003c0bd8fbe393db2dcac6b (patch) | |
| tree | a01ba73f37570b96bebef8c193abaf686ef9f696 /main.ha | |
| parent | d6181b5e4f6f2dc72907e9f2e73db9ce0075cddd (diff) | |
add header command
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]); }; }; |
