Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sorairolake/sysexits-zig

The system exit codes as defined by <sysexits.h> for Zig
https://github.com/sorairolake/sysexits-zig

exitcode sysexits zig zig-library zig-package ziglang

Last synced: 2 days ago
JSON representation

The system exit codes as defined by <sysexits.h> for Zig

Awesome Lists containing this project

README

        

# sysexits-zig

[![CI][ci-badge]][ci-url]

**sysexits-zig** is a library that provides the system exit code constants as
defined by [``].

This library is a port of [sysexits-rs].

## Usage

Add this package to your `build.zig.zon`:

```sh
zig fetch --save git+https://github.com/sorairolake/sysexits-zig.git
```

Add the following to your `build.zig`:

```zig
const sysexits = b.dependency("sysexits", .{});
exe.root_module.addImport("sysexits", sysexits.module("sysexits"));
```

### Example

```zig
const std = @import("std");

const sysexits = @import("sysexits");

pub fn main() !u8 {
const bytes = [_]u8{ 0xf0, 0x9f, 0x92, 0x96 };
if (std.unicode.utf8ValidateSlice(&bytes)) {
try std.io.getStdOut().writer().print("{s}\n", .{bytes});
return @intFromEnum(sysexits.ExitCode.ok);
} else {
try std.io.getStdErr().writer().print("Error: invalid UTF-8 sequence\n", .{});
return @intFromEnum(sysexits.ExitCode.data_err);
}
}
```

### Documentation

To build the documentation:

```sh
zig build doc
```

The result is generated in `zig-out/docs`.

If you want to preview this, run a HTTP server locally. For example:

```sh
python -m http.server -d zig-out/docs
```

Then open `http://localhost:8000/` in your browser.

## Zig version

This library is compatible with Zig version 0.13.0.

## Source code

The upstream repository is available at
.

The source code is also available at:

-
-

## Changelog

Please see [CHANGELOG.adoc].

## Contributing

Please see [CONTRIBUTING.adoc].

## Similar projects

- (Julia)
- (Rust)

You can discover more projects at
.

## License

Copyright © 2023–2024 Shun Sakai (see [AUTHORS.adoc])

This library is distributed under the terms of either the _Apache License 2.0_
or the _MIT License_.

This project is compliant with version 3.2 of the [_REUSE Specification_]. See
copyright notices of individual files for more details on copyright and
licensing information.

[ci-badge]: https://img.shields.io/github/actions/workflow/status/sorairolake/sysexits-zig/CI.yaml?branch=develop&style=for-the-badge&logo=github&label=CI
[ci-url]: https://github.com/sorairolake/sysexits-zig/actions?query=branch%3Adevelop+workflow%3ACI++
[``]: https://man.openbsd.org/sysexits
[sysexits-rs]: https://crates.io/crates/sysexits
[CHANGELOG.adoc]: CHANGELOG.adoc
[CONTRIBUTING.adoc]: CONTRIBUTING.adoc
[AUTHORS.adoc]: AUTHORS.adoc
[_REUSE Specification_]: https://reuse.software/spec/