Skip to content

Commit 0e10a53

Browse files
committed
Error when no target is specified
1 parent 8a0a252 commit 0e10a53

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/main.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ const AccessError = std.os.AccessError;
99
// TODO: Add --help and --verbose flags
1010

1111
const Findup = struct { program: []u8, target: ?[]u8, cwd: Dir };
12+
const FindupError = error{NoFileSpecified};
1213

1314
pub 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{

0 commit comments

Comments
 (0)