This commit is contained in:
parent
bd6e09bf50
commit
1f6cb4eb0c
2 changed files with 29 additions and 2 deletions
|
@ -150,7 +150,12 @@ pub fn build(b: *std.Build) !void {
|
|||
});
|
||||
const options = b.addOptions();
|
||||
options.addOption(bool, "long_tests", long_tests);
|
||||
mod.addImport("build_options", options.createModule());
|
||||
|
||||
const git_describe = b.run(&.{ "git", "describe", "--always", "--dirty" });
|
||||
options.addOption([]const u8, "version", git_describe);
|
||||
|
||||
const options_module = options.createModule();
|
||||
mod.addImport("build_options", options_module);
|
||||
mod.linkLibrary(lib);
|
||||
mod.addIncludePath(upstream.path("include"));
|
||||
|
||||
|
@ -192,6 +197,7 @@ pub fn build(b: *std.Build) !void {
|
|||
// can be extremely useful in case of collisions (which can happen
|
||||
// importing modules from different packages).
|
||||
.{ .name = "pos", .module = mod },
|
||||
.{ .name = "build_options", .module = options_module },
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
|
23
src/main.zig
23
src/main.zig
|
@ -1,6 +1,7 @@
|
|||
const builtin = @import("builtin");
|
||||
const std = @import("std");
|
||||
const pos = @import("pos");
|
||||
const build_options = @import("build_options");
|
||||
|
||||
fn loadReplacements(allocator: std.mem.Allocator) !std.StringHashMap([]const u8) {
|
||||
var replacements = std.StringHashMap([]const u8).init(allocator);
|
||||
|
@ -305,7 +306,27 @@ pub fn main() !u8 {
|
|||
sentence_parse_only = .sentence
|
||||
else if (std.mem.eql(u8, arg, "--command-parse-only"))
|
||||
sentence_parse_only = .command
|
||||
else if (sentence_arg == null)
|
||||
else if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) {
|
||||
var stdout_writer = std.fs.File.stdout().writer(&.{});
|
||||
const stdout = &stdout_writer.interface;
|
||||
try stdout.print(
|
||||
\\pos version {s}
|
||||
\\
|
||||
\\Usage: {s} [OPTIONS] <sentence>
|
||||
\\
|
||||
\\Options:
|
||||
\\ --sentence-parse-only Parse sentence and show parse tree
|
||||
\\ --command-parse-only Parse as command with replacements
|
||||
\\ --help, -h Show this help message
|
||||
\\
|
||||
\\Configuration:
|
||||
\\ Replacements are loaded from:
|
||||
\\ 1. ./replacements.json (current directory)
|
||||
\\ 2. XDG_CONFIG_HOME/pos/replacements.json
|
||||
\\
|
||||
, .{ build_options.version, args[0] });
|
||||
return 0;
|
||||
} else if (sentence_arg == null)
|
||||
sentence_arg = arg;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue