tangled
alpha
login
or
join now
brookjeynes.dev
/
jido
7
fork
atom
地圖 (Jido) is a lightweight Unix TUI file explorer designed for speed and simplicity.
7
fork
atom
overview
issues
pulls
pipelines
feat: Added [-v | --version] and [-h | --help] args.
brookjeynes.dev
11 months ago
7dea38a7
f9515e37
+48
-6
4 changed files
expand all
collapse all
unified
split
CHANGELOG.md
build.zig
build.zig.zon
src
main.zig
+3
CHANGELOG.md
···
1
1
# Changelog
2
2
3
3
+
## v0.9.5 (2025-03-29)
4
4
+
- feat: Added [-v | --version] and [-h | --help] args.
5
5
+
3
6
## v0.9.4 (2025-03-29)
4
7
- feat: Added keybind `h` to view help / keybind menu.
5
8
- refactor: `List` drawing logic is now handled by the `Drawer{}`.
+20
-5
build.zig
···
1
1
const std = @import("std");
2
2
const builtin = @import("builtin");
3
3
4
4
+
///Must match the `version` in `build.zig.zon`.
5
5
+
const version = std.SemanticVersion{ .major = 0, .minor = 9, .patch = 5 };
6
6
+
4
7
const targets: []const std.Target.Query = &.{
5
8
.{ .cpu_arch = .aarch64, .os_tag = .macos },
6
9
.{ .cpu_arch = .aarch64, .os_tag = .linux },
···
8
11
.{ .cpu_arch = .x86_64, .os_tag = .macos },
9
12
};
10
13
11
11
-
fn createExe(b: *std.Build, exe_name: []const u8, target: std.Build.ResolvedTarget, optimize: std.builtin.OptimizeMode) !*std.Build.Step.Compile {
14
14
+
fn createExe(
15
15
+
b: *std.Build,
16
16
+
exe_name: []const u8,
17
17
+
target: std.Build.ResolvedTarget,
18
18
+
optimize: std.builtin.OptimizeMode,
19
19
+
build_options: *std.Build.Module,
20
20
+
) !*std.Build.Step.Compile {
12
21
const libvaxis = b.dependency("vaxis", .{ .target = target }).module("vaxis");
13
22
const fuzzig = b.dependency("fuzzig", .{ .target = target }).module("fuzzig");
14
23
const zuid = b.dependency("zuid", .{ .target = target }).module("zuid");
···
21
30
.optimize = optimize,
22
31
});
23
32
33
33
+
exe.root_module.addImport("options", build_options);
24
34
exe.root_module.addImport("vaxis", libvaxis);
25
35
exe.root_module.addImport("fuzzig", fuzzig);
26
36
exe.root_module.addImport("zuid", zuid);
···
33
43
const target = b.standardTargetOptions(.{});
34
44
const optimize = b.standardOptimizeOption(.{});
35
45
46
46
+
const build_options = b.addOptions();
47
47
+
build_options.step.name = "build options";
48
48
+
build_options.addOption(std.SemanticVersion, "version", version);
49
49
+
const build_options_module = build_options.createModule();
50
50
+
36
51
// Building targets for release.
37
52
const build_all = b.option(bool, "all-targets", "Build all targets in ReleaseSafe mode.") orelse false;
38
53
if (build_all) {
39
39
-
try buildTargets(b);
54
54
+
try buildTargets(b, build_options_module);
40
55
return;
41
56
}
42
57
43
43
-
const exe = try createExe(b, "jido", target, optimize);
58
58
+
const exe = try createExe(b, "jido", target, optimize, build_options_module);
44
59
b.installArtifact(exe);
45
60
46
61
const run_cmd = b.addRunArtifact(exe);
···
52
67
run_step.dependOn(&run_cmd.step);
53
68
}
54
69
55
55
-
fn buildTargets(b: *std.Build) !void {
70
70
+
fn buildTargets(b: *std.Build, build_options: *std.Build.Module) !void {
56
71
for (targets) |t| {
57
72
const target = b.resolveTargetQuery(t);
58
73
59
59
-
const exe = try createExe(b, "jido", target, .ReleaseSafe);
74
74
+
const exe = try createExe(b, "jido", target, .ReleaseSafe, build_options);
60
75
b.installArtifact(exe);
61
76
62
77
const target_output = b.addInstallArtifact(exe, .{
+1
-1
build.zig.zon
···
1
1
.{
2
2
.name = .jido,
3
3
.fingerprint = 0xee45eabe36cafb57,
4
4
-
.version = "0.9.4",
4
4
+
.version = "0.9.5",
5
5
.minimum_zig_version = "0.14.0",
6
6
7
7
.dependencies = .{
+24
src/main.zig
···
1
1
const std = @import("std");
2
2
const builtin = @import("builtin");
3
3
+
const options = @import("options");
3
4
const App = @import("app.zig");
4
5
const FileLogger = @import("file_logger.zig");
5
6
const vaxis = @import("vaxis");
···
23
24
}
24
25
}
25
26
const alloc = gpa.allocator();
27
27
+
28
28
+
var args = std.process.args();
29
29
+
_ = args.skip();
30
30
+
if (args.next()) |arg| {
31
31
+
if (std.mem.eql(u8, arg, "--version") or std.mem.eql(u8, arg, "-v")) {
32
32
+
std.debug.print("jido v{}\n", .{options.version});
33
33
+
return;
34
34
+
}
35
35
+
36
36
+
if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) {
37
37
+
std.debug.print(
38
38
+
\\Usage: jido
39
39
+
\\
40
40
+
\\a lightweight Unix TUI file explorer
41
41
+
\\
42
42
+
\\Flags:
43
43
+
\\ -h, --help Show help information and exit.
44
44
+
\\ -v, --version Print version information and exit.
45
45
+
\\
46
46
+
, .{});
47
47
+
return;
48
48
+
}
49
49
+
}
26
50
27
51
var app = try App.init(alloc);
28
52
defer app.deinit();