diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/main.zig b/src/main.zig index c7e3844..b4f06a7 100644 --- a/src/main.zig +++ b/src/main.zig | |||
| @@ -16,6 +16,7 @@ const std = @import("std"); | |||
| 16 | const zup_config = @import("zup-config"); | 16 | const zup_config = @import("zup-config"); |
| 17 | 17 | ||
| 18 | const ArgIterator = std.process.ArgIterator; | 18 | const ArgIterator = std.process.ArgIterator; |
| 19 | const File = std.fs.File; | ||
| 19 | const GPA = std.heap.GeneralPurposeAllocator(.{}); | 20 | const GPA = std.heap.GeneralPurposeAllocator(.{}); |
| 20 | const StaticStringMap = std.StaticStringMap; | 21 | const StaticStringMap = std.StaticStringMap; |
| 21 | const Tuple = std.meta.Tuple; | 22 | const Tuple = std.meta.Tuple; |
| @@ -40,7 +41,10 @@ pub fn main() !void { | |||
| 40 | } | 41 | } |
| 41 | 42 | ||
| 42 | pub fn printVersion() !void { | 43 | pub fn printVersion() !void { |
| 43 | return std.io.getStdErr().writer().print("{}\n", .{zup_config.version}); | 44 | var buf: [1024]u8 = undefined; |
| 45 | var stderr = File.stderr().writer(&buf); | ||
| 46 | try stderr.interface.print("{f}\n", .{zup_config.version}); | ||
| 47 | return stderr.interface.flush(); | ||
| 44 | } | 48 | } |
| 45 | 49 | ||
| 46 | const Command = enum { | 50 | const Command = enum { |
| @@ -106,8 +110,9 @@ const Help = struct { | |||
| 106 | } | 110 | } |
| 107 | 111 | ||
| 108 | pub fn mainHelp() !void { | 112 | pub fn mainHelp() !void { |
| 109 | const writer = std.io.getStdErr().writer(); | 113 | var buf: [1024]u8 = undefined; |
| 110 | try writer.writeAll( | 114 | var stderr = File.stderr().writer(&buf); |
| 115 | try stderr.interface.writeAll( | ||
| 111 | \\USAGE: zup <COMMAND> | 116 | \\USAGE: zup <COMMAND> |
| 112 | \\ | 117 | \\ |
| 113 | \\These are the common Zup commands: | 118 | \\These are the common Zup commands: |
| @@ -123,6 +128,7 @@ const Help = struct { | |||
| 123 | \\You can find out more about a command by running `zup help <command>`. | 128 | \\You can find out more about a command by running `zup help <command>`. |
| 124 | \\ | 129 | \\ |
| 125 | ); | 130 | ); |
| 131 | return stderr.interface.flush(); | ||
| 126 | } | 132 | } |
| 127 | 133 | ||
| 128 | fn unknownHelp(cmd: []const u8) !void { | 134 | fn unknownHelp(cmd: []const u8) !void { |
| @@ -142,7 +148,3 @@ const Version = struct { | |||
| 142 | return printVersion(); | 148 | return printVersion(); |
| 143 | } | 149 | } |
| 144 | }; | 150 | }; |
| 145 | |||
| 146 | test "basic test" { | ||
| 147 | try std.testing.expectEqual(10, 3 + 7); | ||
| 148 | } | ||