summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-07-22 06:29:25 +0300
committerGravatar Uko Kokņevičs2025-07-22 06:29:25 +0300
commit73fd32eb28753584edb160fc11b0c16078a2ed6d (patch)
tree6ced78d1293bea471d6fb3dd29a57e860960385e /src/main.zig
parentDocument that zup 0.6.0 compiles with zig 0.14.1 as well (diff)
downloadzup-main.tar.gz
zup-main.tar.xz
zup-main.zip
Update ZigHEADmain
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig16
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");
16const zup_config = @import("zup-config"); 16const zup_config = @import("zup-config");
17 17
18const ArgIterator = std.process.ArgIterator; 18const ArgIterator = std.process.ArgIterator;
19const File = std.fs.File;
19const GPA = std.heap.GeneralPurposeAllocator(.{}); 20const GPA = std.heap.GeneralPurposeAllocator(.{});
20const StaticStringMap = std.StaticStringMap; 21const StaticStringMap = std.StaticStringMap;
21const Tuple = std.meta.Tuple; 22const Tuple = std.meta.Tuple;
@@ -40,7 +41,10 @@ pub fn main() !void {
40} 41}
41 42
42pub fn printVersion() !void { 43pub 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
46const Command = enum { 50const 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
146test "basic test" {
147 try std.testing.expectEqual(10, 3 + 7);
148}