19 releases (2 stable)

2.0.1 Feb 12, 2024
2.0.0 Jan 25, 2024
0.5.0 Apr 21, 2020
0.4.9 Apr 16, 2020
0.1.2 Jan 11, 2020

#63 in Operating systems

Download history 3/week @ 2024-01-23 10/week @ 2024-02-06 20/week @ 2024-02-13 23/week @ 2024-02-20 19/week @ 2024-02-27 1/week @ 2024-03-05 21/week @ 2024-03-26 84/week @ 2024-04-02

106 downloads per month

MIT and GPL-3.0-only

38KB
866 lines

FCTool

The better solution for shell-scripts.

Installation

  1. Install Cargo
  2. Run cargo install fctool

Usage

fctool {input file}

Examples

See the 'examples' directory in the repository.

Doc

Hello world

Hello, world!

Write to and overwrite a file

![file.txt]

Write but don't overwrite

[file.txt]

Define a variable

var = text

Reference a variable

{var}

Read from pipe

%foriter
    line {line_i}: {line}
%endfor

Iterate lines of specified expression

%for line : {$["text.txt"]}
    prefix {line} suffix
%endfor

Iterate with specified split string of specified expression

%for line : {$["/etc/passwd"]}
    %for column : {colon} : {line}
        {column}
    %endfor
    %l
%endfor

Execute a command

{$("echo 1")}

Read a file

{$["file.txt"]}

If else

%if {var == "value" || other == "foobar"}
    condition was true!
%elif {var == "foo"}
    Elif true!
%else
    Else
%endif

User input

user_input = {input("enter value: ")}

Exit process

{exit}

Source another fctool-file

{source("other.fctool")}

Math!

{x + y} Add
{x - y} Sub
{x * y} Mul
{x / y} Div
{x % y} Mod
{x ^ y} Pow

Funtions

%func add a b
    %ret {a + b}
%endfunc

{add(1, 2)}

Regex matching

%if {match(".+", "abc")}
    matches!
%endif

Line break

%l

Input text into a command

$$[cat]
hello
to
cat

Use control character variables
{ left_brace
} right_brace
: colon
; semicolon
% percent

Dependencies

~4.5–7.5MB
~118K SLoC