Skip to content

Commit

Permalink
Renamed executable to 'sapt'
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelo committed Oct 2, 2021
1 parent 6c5fc95 commit c45cb5f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn build(b: *std.build.Builder) void {
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall.
const mode = b.standardReleaseOptions();

const exe = b.addExecutable("apitester", "src/main.zig");
const exe = b.addExecutable("sapt", "src/main.zig");
exe.linkSystemLibrary("c");
// exe.initExtraArgs(linkage = exe.Linkage.static);
exe.linkSystemLibrary("libcurl"); // TODO: verify if it's statically
Expand Down
20 changes: 16 additions & 4 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -164,13 +164,20 @@ const AppArguments = struct {
files: std.BoundedArray(FilePathEntry,128) = initBoundedArray(FilePathEntry, 128),
};

fn printHelp() void {
fn printHelp(full: bool) void {

debug(
\\
\\{0s} v{1s} - Simple API Tester
\\
\\Usage: {0s} [arguments] file1 [file2 ... fileN]
\\
, .{APP_NAME, APP_VERSION}
);

if(!full) return;

debug(
\\{0s} gettoken.pi testsuite1/*
\\{0s} -p=myplaybook.book
\\{0s} -p=myplaybook.book -s -o=output.log
Expand All @@ -186,7 +193,7 @@ fn printHelp() void {
\\ -o=file Redirect all output to file
\\ -p=playbook Read tests to perform from playbook-file -- not implemented yet
\\
, .{APP_NAME, APP_VERSION}
, .{APP_NAME}
);
}

Expand Down Expand Up @@ -516,6 +523,11 @@ pub fn main() !void {
const args = try std.process.argsAlloc(aa);
defer std.process.argsFree(aa, args);

if(args.len == 1) {
printHelp(false);
std.process.exit(0);
}

mainInner(args[1..]) catch |e| {
fatal("Exited due to failure ({s})\n", .{e});
};
Expand All @@ -533,8 +545,8 @@ pub fn mainInner(args: [][]u8) anyerror!void {
// TODO: Filter input-set first, to get the proper number of items? Or at least count them up

var parsed_args = parseArgs(args) catch |e| switch(e) {
error.ShowHelp => { printHelp(); return; },
else => { debug("Invalid arguments.\n" ,.{}); printHelp(); fatal("Exiting.", .{}); }
error.ShowHelp => { printHelp(true); return; },
else => { debug("Invalid arguments.\n" ,.{}); printHelp(true); fatal("Exiting.", .{}); }
};

processInputFileArguments(parsed_args.files.buffer.len, &parsed_args.files) catch |e| {
Expand Down

0 comments on commit c45cb5f

Please sign in to comment.