Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/taylorwood/clj.native-cli
Template for creating native CLI tools with Clojure and GraalVM
https://github.com/taylorwood/clj.native-cli
cli clojure graalvm native-image template
Last synced: 3 months ago
JSON representation
Template for creating native CLI tools with Clojure and GraalVM
- Host: GitHub
- URL: https://github.com/taylorwood/clj.native-cli
- Owner: taylorwood
- License: epl-2.0
- Created: 2018-09-29T22:44:05.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-10-20T14:36:35.000Z (over 5 years ago)
- Last Synced: 2024-08-03T13:04:59.341Z (6 months ago)
- Topics: cli, clojure, graalvm, native-image, template
- Language: Clojure
- Size: 11.7 KB
- Stars: 22
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clj.native-cli
This project serves as a starting point for creating native CLI tools with Clojure
and GraalVM.The template uses Clojure 1.9, clojure.tools.cli for argument parsing, and [clj.native-image](https://github.com/taylorwood/clj.native-image) for GraalVM `native-image` integration.
## Usage
1. Obtain the template:
- Use GitHub's [create from template](https://github.com/taylorwood/clj.native-cli/generate) feature, or...
- Download/unpack the latest release into a directory e.g. `my-script-name`:
```bash
$ curl -L https://github.com/taylorwood/clj.native-cli/archive/v0.0.2.tar.gz > release.tar.gz \
&& tar -xzf release.tar.gz && rm release.tar.gz \
&& mv clj.native-cli-0.0.2 my-script-name
```
1. Make `src/script.clj` do something interesting. See `deps.edn` for dependencies and `clj.native-image` options.
1. Run your program e.g. print CLI usage help:
```bash
$ clojure -m script -h
Usage:
-h, --help
```
1. Compile a native executable:
```bash
$ clojure -A:native-image
$ ./script -h
Usage:
-h, --help
```You may find a script useful for instantiating this template:
```bash
#!/usr/bin/env bash
SCRIPT_NAME=$1
RELEASE_VER="0.0.2"
[[ -z "$SCRIPT_NAME" ]] && echo "A script name is required!" && exit 1
curl -L https://github.com/taylorwood/clj.native-cli/archive/v${RELEASE_VER}.tar.gz > release.tar.gz \
&& tar -xzf release.tar.gz && rm release.tar.gz \
&& mv clj.native-cli-${RELEASE_VER} ${SCRIPT_NAME}
```
And execute it with some script name:
```bash
$ ./new-clj-script my-script-name
```