File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,14 +9,15 @@ const AccessError = std.os.AccessError;
99// TODO: Add --help and --verbose flags
1010
1111const Findup = struct { program : []u8 , target : ? []u8 , cwd : Dir };
12+ const FindupError = error {NoFileSpecified };
1213
1314pub fn main () anyerror ! void {
1415 var arena = std .heap .ArenaAllocator .init (std .heap .page_allocator );
1516 defer arena .deinit ();
1617 var buf : [MAX_PATH_BYTES ]u8 = undefined ;
1718
1819 const findup = initFindup (& arena .allocator ) catch | err | {
19- try stderr .print ("error encountered : {e}\n " , .{err });
20+ try stderr .print ("ERROR : {e}\n " , .{err });
2021 try stderr .print ("Usage: findup FILE\n " , .{});
2122 std .os .exit (1 );
2223 };
@@ -42,7 +43,7 @@ fn initFindup(allocator: *std.mem.Allocator) anyerror!Findup {
4243
4344 const program = try args .next (allocator ).? ;
4445 const maybeTarget = args .next (allocator );
45- const target = if (maybeTarget == null ) null else try maybeTarget .? ;
46+ const target = if (maybeTarget == null ) return FindupError . NoFileSpecified else try maybeTarget .? ;
4647 const cwd = std .fs .cwd ();
4748
4849 return Findup {
You can’t perform that action at this time.
0 commit comments