Ecosyste.ms: Awesome

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

https://github.com/jiacai2050/zigcli

A toolkit for building command lines programs in Zig.
https://github.com/jiacai2050/zigcli

cli lines-of-code tree zig zig-package

Last synced: about 1 month ago
JSON representation

A toolkit for building command lines programs in Zig.

Lists

README

        

#+TITLE: Zigcli
#+DATE: 2023-10-21T12:09:48+0800
#+LASTMOD: 2024-05-02T18:01:55+0800
#+TYPE: docs

[[https://github.com/jiacai2050/zigcli/stargazers][https://img.shields.io/github/stars/jiacai2050/zigcli.svg]]
[[https://github.com/jiacai2050/zigcli/blob/main/LICENSE][https://img.shields.io/github/license/jiacai2050/zigcli.svg]]
[[https://github.com/jiacai2050/loc/actions/workflows/CI.yml][https://github.com/jiacai2050/loc/actions/workflows/CI.yml/badge.svg]]
[[https://github.com/jiacai2050/loc/actions/workflows/binary.yml][https://github.com/jiacai2050/loc/actions/workflows/binary.yml/badge.svg]]
[[https://img.shields.io/badge/zig%20version-0.12.0-blue.svg]]

#+begin_quote
[[/][Zigcli]] is a toolkit for building command lines programs in Zig.
#+end_quote

This package provides:
- Modules :: Zig [[https://ziglang.org/download/0.11.0/release-notes.html#Package-Management][modules]] to help developers build their awesome cli programs. Currently there are:
- =simargs=, which is used to parse arguments
- =pretty-table=, which is used to print aligned and formatted tables

- Programs :: Practical command line programs which can be used directly. Currently there are:
- =loc=, lines of code.
- =tree=, list contents of directories in a tree-like format.
- =yes=, output a string repeatedly until killed.
- =repeat=, repeat a command until it succeeds.
- =pidof=, like [[https://man7.org/linux/man-pages/man1/pidof.1.html][pidof]], but for macOS.
- =night-shift=, control [[https://support.apple.com/guide/mac-help/use-night-shift-mchl97bc676d/mac][Night Shift]] in macOS.
- =dark-mode=, control dark mode in macOS.

* Install
** Programs
Prebuilt binaries can be found in [[https://github.com/jiacai2050/loc/actions/workflows/binary.yml][CI's artifacts]], or you can build from source:
#+begin_src bash
git clone https://github.com/jiacai2050/zigcli.git
#+end_src
Then build with
#+begin_src bash
make build
#+end_src

#+begin_quote
To build zigcli locally, Zig master is required, which can be downloaded [[https://ziglang.org/download/][here]].
#+end_quote

** Modules
=zigcli= support [[https://ziglang.org/download/0.11.0/release-notes.html#Package-Management][package manager]] introduced in Zig 0.11.

#+begin_src bash
zig fetch --save=zigcli https://github.com/jiacai2050/zigcli/archive/${COMMIT}.tar.gz
#+end_src

#+RESULTS:

Replace ~${COMMIT}~ with a real one, then in your =build.zig=, import the module like this:

#+begin_src zig
const zigcli = b.dependency("zigcli", .{});

// Currently zigcli provide two modules.
exe.root_module.addImport("simargs", zigcli.module("simargs"));
exe.root_module.addImport("pretty-table", zigcli.module("pretty-table"));
#+end_src

* Who's Using
If you're using =zigcli=, and would like to be added here, welcome to [[https://github.com/jiacai2050/zigcli/pulls][open a PR]].

* Roadmap
** Loc
- Performance, at least comparable with [[https://github.com/cgag/loc][cgag/loc]] [[https://github.com/jiacai2050/loc/issues/1][#1]]
- More options, such as =--exclude =
- Support multiline comment
* License
MIT, see [[https://github.com/jiacai2050/zigcli/blob/main/LICENSE][LICENSE]] for details.