Skip to content

Commit 4ac4556

Browse files
authored
feat: add initial script (#1)
1 parent 926b95d commit 4ac4556

File tree

6 files changed

+554
-8
lines changed

6 files changed

+554
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.zig-cache/
2+
zig-out/

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
# fetch
2-
zig test
1+
# Zfetch
2+
3+
A fast and modern [Neofetch](https://github.com/dylanaraps/neofetch)-like tool made in Zig.
4+
5+
> [!CAUTION]
6+
> **Important**: This is an early stage project and may not have undergone
7+
> extensive testing. Please be aware that Zig is still in its early
8+
> phases, and breaking changes may occur between minor versions.
9+
10+
## Build
11+
12+
To build Zfetch, ensure you're using Zig 0.14.0.
13+
14+
```bash
15+
zig build -Doptimize=ReleaseFast
16+
```
17+
18+
For the best performance, we recommend building with optimizations enabled.
19+
20+
## Contribution
21+
22+
While we're excited about the future of Zfetch, we're not yet open to contributions.
23+
However, your feedback is invaluable! Please feel free to submit issues if you
24+
encounter any errors or if you have feature requests. Your input will help
25+
guide future development.
26+
27+
---
28+
29+
Thank you for your insterest in Zfetch! We appreciate your understanding as we navigate the early stages of development.

build.zig

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
const std = @import("std");
2+
3+
// Although this function looks imperative, note that its job is to
4+
// declaratively construct a build graph that will be executed by an external
5+
// runner.
6+
pub fn build(b: *std.Build) void {
7+
// Standard target options allows the person to customize the target
8+
// architecture and OS. In this case, we support all OS.
9+
const target = b.standardTargetOptions(.{});
10+
11+
// Standard optimization options allow the person to select between
12+
// debug, release-safe, release-fast, etc. Release-fast gives us max perf.
13+
const optimize = b.standardOptimizeOption(.{});
14+
15+
const exe = b.addExecutable(.{
16+
.name = "zfetch",
17+
.root_source_file = b.path("zfetch.zig"),
18+
.target = target,
19+
.optimize = optimize,
20+
});
21+
22+
// This declares intent for the executable to be installed into the
23+
// standard location when the user invokes the "install" step
24+
b.installArtifact(exe);
25+
26+
// Creates a step for executing the artifact
27+
const run_cmd = b.addRunArtifact(exe);
28+
run_cmd.step.dependOn(b.getInstallStep());
29+
30+
// By making the run step depend on the install step, it will be run from the
31+
// installation directory rather than directly from within the cache directory.
32+
// This is not necessary, however, if the application depends on other installed
33+
// files, this ensures they will be present and in the expected location.
34+
if (b.args) |args| {
35+
run_cmd.addArgs(args);
36+
}
37+
38+
// This creates a build step. It will be visible in the `zig build --help` menu,
39+
// and can be selected like this: `zig build run`
40+
const run_step = b.step("run", "Run zfetch");
41+
run_step.dependOn(&run_cmd.step);
42+
43+
// Creates a step for unit testing. This only builds the test executable
44+
// but does not run it.
45+
const unit_tests = b.addTest(.{
46+
.root_source_file = b.path("zfetch.zig"),
47+
.target = target,
48+
.optimize = optimize,
49+
});
50+
51+
const run_unit_tests = b.addRunArtifact(unit_tests);
52+
53+
// Similar to creating the run step earlier, this exposes a `test` step to
54+
// the `zig build --help` menu, providing a way for the user to request
55+
// running the unit tests.
56+
const test_step = b.step("test", "Run unit tests");
57+
test_step.dependOn(&run_unit_tests.step);
58+
}

build.zig.zon

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.{
2+
// This is the default name used by packages depending on this one. For
3+
// example, when a user runs `zig fetch --save <url>`, this field is used
4+
// as the key in the `dependencies` table. Although the user can choose a
5+
// different name, most users will stick with this provided value.
6+
//
7+
// It is redundant to include "zig" in this name because it is already
8+
// within the Zig package namespace.
9+
.name = "zfetch",
10+
11+
// This is a [Semantic Version](https://semver.org/).
12+
// In a future version of Zig it will be used for package deduplication.
13+
.version = "0.0.0",
14+
15+
// Together with name, this represents a globally unique package
16+
// identifier. This field is generated by the Zig toolchain when the
17+
// package is first created, and then *never changes*. This allows
18+
// unambiguous detection of one package being an updated version of
19+
// another.
20+
//
21+
// When forking a Zig project, this id should be regenerated (delete the
22+
// field and run `zig build`) if the upstream project is still maintained.
23+
// Otherwise, the fork is *hostile*, attempting to take control over the
24+
// original project's identity. Thus it is recommended to leave the comment
25+
// on the following line intact, so that it shows up in code reviews that
26+
// modify the field.
27+
.fingerprint = 0x5fb01b5abcaf00bb, // Changing this has security and trust implications.
28+
29+
// Tracks the earliest Zig version that the package considers to be a
30+
// supported use case.
31+
.minimum_zig_version = "0.14.0",
32+
33+
// This field is optional.
34+
// Each dependency must either provide a `url` and `hash`, or a `path`.
35+
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
36+
// Once all dependencies are fetched, `zig build` no longer requires
37+
// internet connectivity.
38+
.dependencies = .{
39+
// See `zig fetch --save <url>` for a command-line interface for adding dependencies.
40+
//.example = .{
41+
// // When updating this field to a new URL, be sure to delete the corresponding
42+
// // `hash`, otherwise you are communicating that you expect to find the old hash at
43+
// // the new URL. If the contents of a URL change this will result in a hash mismatch
44+
// // which will prevent zig from using it.
45+
// .url = "https://example.com/foo.tar.gz",
46+
//
47+
// // This is computed from the file contents of the directory of files that is
48+
// // obtained after fetching `url` and applying the inclusion rules given by
49+
// // `paths`.
50+
// //
51+
// // This field is the source of truth; packages do not come from a `url`; they
52+
// // come from a `hash`. `url` is just one of many possible mirrors for how to
53+
// // obtain a package matching this `hash`.
54+
// //
55+
// // Uses the [multihash](https://multiformats.io/multihash/) format.
56+
// .hash = "...",
57+
//
58+
// // When this is provided, the package is found in a directory relative to the
59+
// // build root. In this case the package's hash is irrelevant and therefore not
60+
// // computed. This field and `url` are mutually exclusive.
61+
// .path = "foo",
62+
//
63+
// // When this is set to `true`, a package is declared to be lazily
64+
// // fetched. This makes the dependency only get fetched if it is
65+
// // actually used.
66+
// .lazy = false,
67+
//},
68+
},
69+
70+
// Specifies the set of files and directories that are included in this package.
71+
// Only files and directories listed here are included in the `hash` that
72+
// is computed for this package. Only files listed here will remain on disk
73+
// when using the zig package manager. As a rule of thumb, one should list
74+
// files required for compilation plus any license(s).
75+
// Paths are relative to the build root. Use the empty string (`""`) to refer to
76+
// the build root itself.
77+
// A directory listed here means that all files within, recursively, are included.
78+
.paths = .{
79+
"build.zig",
80+
"build.zig.zon",
81+
"src",
82+
// For example...
83+
//"LICENSE",
84+
//"README.md",
85+
},
86+
}

hello-world.zig

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)