• This repository has been archived on 06/Aug/2020
  • Stars
    star
    12
  • Rank 1,546,328 (Top 32 %)
  • Language
    Julia
  • License
    Other
  • Created about 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Converts amost every Julia object to CLI commands

CLI

Please use my latest project as a replacement Comonicon

CLI.jl is a library for automatically generating command line interfaces from absolutely Julia object. Is is highly inspired by python-fire. But thanks to Julia's powerful metaprogramming, we are able to do this in a much easier way. CLI.jl make use of Julia's metaprogramming and multiple dispatch feature.

warning It only supports *nix systems at the moment. I have not tested it for Windows. Julia v0.6+ is required. Still under development.

Features

Installation

Pkg.clone(git@github.com:Roger-luo/CLI.jl.git)

Basic Usage

You can call @command on julia functions.

#demo.jl

using CLI

@command """
this is a demo CLI
"""


"""
add up
"""
@command function add(x::Int, y::Int; extra::Int=1)
    x + y + extra
end

main()
> demo.jl --help
[SYNOPSIS]
	demo2.jl [-h,--help] [-v,--version] <command>
[DESCRIPTION]
	this is a demo CLI

[COMMANDS]
	add
	  add up

Advanced

You can create subcommands using Julia's modules. And then you can compile it to a binary application by PackageCompiler.jl

Use subcommands and Compile to Binary

# demo.jl
module demo
using CLI

@command """
this is a demo CLI
"""

module math
using CLI

@command """
math calculations
"""

"""
add up
"""
@command function add(x::Int, y::Int; extra::Int=1)
    x + y + extra
end

"""
multiply two integers
"""
@command mul(x::Int, y::Int) = x * y

end # math

"""
plus two integers
"""
@command function plus(x::Int, y::Int)
    x + y    
end

Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
    main()
end

end

then open a Julia REPL, type

> julia using PackageCompiler; build_executable("demo.jl")

you will get an binary demo, simply copy it to where you want and use it. This will reduce your CLI start time significantly. Enjoy!

Advanced Customize

CLI.jl offers several types to store your CLI application. You can directly use them to build a CLI application.

using CLI

add(x::Int, y::Int) = x + y
mul(x::Int, y::Int) = x * y

leaf1 = LeafCommand(:add, add, Signature([Int, Int], []))
leaf2 = LeafCommand(:mul, mul, Signature([Int, Int], []))
node = NodeCommand("math", [leaf1, leaf2])

maincmd = MainCommand("cal", [], [node])

stream = ARGStream(ARGS)
resolve(stream, maincmd; debug=false)

CLI Design Guidance

CLI.jl accepts most CLI design syntax from GNU CLI Standard, IEEE and other *nix external programs, e.g git, ls, etc.

Future Plans

  • support @command for arbitrary Julia objects
  • further performance improvements (CLI start time)

Author

Roger Luo

More Repositories

1

Brochure.jl

Julia编程指南
Julia
268
star
2

FromFile.jl

Julia enhancement proposal (Julep) for implicit per file module in Julia
Julia
130
star
3

YAAD.jl

Implement you own AD in 300 loc
Julia
77
star
4

Configurations.jl

Options & Configurations made easy.
Julia
66
star
5

Expronicon.jl

Collective tools for metaprogramming on Julia Expr
Julia
54
star
6

TutorialForPhysicists.jl

A Tutorial to Julia Language for Physicists
Jupyter Notebook
54
star
7

IonCLI.jl

The Ion CLI for Julia.
Julia
48
star
8

Ion

Ion - a CLI toolbox for Julia developers
Rust
46
star
9

pytorch-complex

complex tensor plugin for pytorch (deprecated)
C++
46
star
10

YASSAD.jl

Yet Another Source to Source Automatic Differentiation
Julia
26
star
11

GarishPrint.jl

An opinioned pretty printing package for Julia objects.
Julia
23
star
12

PIML

lecture materials of the ML for Physics course 2021 in Perimeter Institute
Julia
19
star
13

QCHS2022

QCHS2022 Summer School Tutorial for Yao and Bloqade
Jupyter Notebook
13
star
14

JuliaCN2022Talk

Julia中文社区报告:罗秀哲的开源工具箱
Vue
13
star
15

QMTK.jl

Quantum Many-body Toolkit (This repo is deprecated, and its components has been seperated to several projects under https://github.com/QuantumBFS.)
Julia
12
star
16

BatchedRoutines.jl

Batched routines (BLAS, LAPACK, etc.) for multi-dimensional arrays
Julia
10
star
17

Ion.jl

REPL/CLI based Developer Toolchain for Julia
Julia
10
star
18

MAGMA.jl

A Julia binding for MAGMA, don't drink it
Julia
10
star
19

ExproniconLite.jl

no fancy pattern matching, no dependencies, lightweight Expronicon for low latency.
Julia
10
star
20

CSIMD

SIMD Accelerated Operations for Complex Numbers.
C
8
star
21

KungIChi.jl

Data validation and settings management in Julia
Julia
7
star
22

juliacon-quantum-bof

Materials for Quantum BOF in JuliaCon 2020
6
star
23

Batched.jl

Batched operations and array types in Julia
Julia
6
star
24

Sym.jl

My Own Symbolic Engine
Julia
5
star
25

AdiaComput.jl

A tweakable quantum adiabatic computation simulator
Jupyter Notebook
5
star
26

TicketToRide.jl

Confidential!
TeX
4
star
27

juliacon2019

Materials of My talk for JuliaCon2019
4
star
28

BatchedArrays.jl

Julia
3
star
29

RogerLuo.jl

Julia
3
star
30

Liang.jl

The next-gen emulation engine for quantum systems
Julia
3
star
31

Lattices.jl

Julia
3
star
32

Kebab

Quantum Computation Framework for Julia (Prototype)
Julia
3
star
33

ion-templates

Julia project templates for Ion
Handlebars
2
star
34

Fine

Roger's Fine slide generator
Python
2
star
35

Qiskit.jl

use Qiskit with Yao
Julia
2
star
36

legacy-slides

Roger Luo's slides
HTML
2
star
37

QuHamiltonian.jl

Domain Specific Language (DSL) for (quantum) Hamiltonian construction.
Julia
2
star
38

QuantumGateRoutines.jl

Simulation routines for quantum gates
Julia
2
star
39

PinGo.jl

The PIQuIL Bingo Generator
Julia
2
star
40

packages

a website to show status and docs of packages I created or maintain
Julia
1
star
41

PHYS490-template

Template repo for PHYS490
Python
1
star
42

MinionsREPL.jl

What if your laptop sings like minions every time you type?
Julia
1
star
43

IonBase.jl

Base package for the IonCLI, one can extend the CLI for internal use using this package.
Julia
1
star
44

Golgi.jl

Enzyme! Transform and roll out!
Julia
1
star
45

RenyiEntropyOfMagic.jl

Julia
1
star
46

Localize.jl

Utils for localization of Julia documents
Julia
1
star
47

Blueprints.jl

abstraction for template/static file rendering
Julia
1
star
48

talk

my public talks
1
star
49

legacy-THCZ

an old try on THCZ: complex tensors support for pytorch
Cuda
1
star
50

Constants.jl

Some Useful Constants for Julia
Julia
1
star
51

BenchmarkSets.jl

syntax for creating benchmark set
1
star
52

blog

my blog
Julia
1
star
53

StochasticOptimizers.jl

Optimizers for noisy loss function
Julia
1
star
54

QIP710

assignment for QIP710 (partly)
TeX
1
star
55

CuBatchedRoutines.jl

batched routines for CUDA
Julia
1
star
56

TH

TH with complex support
C
1
star
57

REPL_timetest

test the Julia's REPL run-up time
Shell
1
star