Git Product home page Git Product logo

specter-cli's Introduction

Specter CLI

An native CLI that uses Specter to transform EDN from stdin.

This CLI is compiled with GraalVM native-image and executed using SCI.

Download

You can get pre-built binaries for macOS and linux under Releases. If your OS is not yet supported, you can try building the CLI yourself.

Usage

Currently the CLI accepts one argument, -e, that represents a Clojure expression. The public vars from com.rpl.specter are referred automatically. The question mark variable is bound to EDN from stdin.

$ echo '{:a {:aa 1} :b {:ba -1 :bb 2}}' | ./specter -e '(transform [MAP-VALS MAP-VALS] inc ?)'
{:a {:aa 2}, :b {:ba 0, :bb 3}}

Status

For now this is mostly a proof of concept to see if I could get Specter working within the contect of SCI and native-image (see this issue).

Implementation details

The configuration contains a number of interesting tweaks:

  • A patch for the com.rpl.specter.impl/closed-source function which originally uses clojure.core/eval, which doesn't work in native images. This is replaced by sci/eval-form.
  • A patch for the com.rpl.specter/path macro which originally uses clojure.core/intern as a side effect during macro-expansion. This is replaced by sci.core/intern.

For GraalVM we need to provide a reflection config that contains clojure.lang.Equiv/equals since the path macro generates code which does interop on this class and this macro is expanded at runtime inside the SCI context. We also need to add clojure.lang.Util to SCI's :classes option for the same reason.

Build

Set GRAALVM_HOME to your local GraalVM install. Run script/build.

License

Copyright © 2021 Michiel Borkent

This Specter CLI is licensed under Apache License v2.0, same as Specter. See LICENSE.

specter-cli's People

Contributors

borkdude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

specter-cli's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.