Giter Club home page Giter Club logo

doit's Introduction

DOIT

The DOIT scripting language is a very simple and basic script for doing common tasks in a project folder. It has built in --help support that is generated from the script itself. Good for quick and simple tasks that aren't complicated and don't need something more complicated like a Makefile.

Why?

So I know you can just use something like a Makefile to build things, but I get quickly frustrated with Makefiles and their crazy complexity. Most of the time I just want something I can put my simple CLI commands in that's easy to modify and maintain. I've previously used NPM for this, but it is painfully slow to run. So instead I built my own basic scripting language that gets transpiled to C++ and then compiled by the GCC to a very fast executable file.

Install

Self Build

  1. Build the project following Build
  2. Link the executable to your usr/bin: sudo ln -s /path/to/project/target/release/doit /usr/local/bin/doit

From Release

  1. Download executable.
  2. Copy to /usr/local/bin or place somewhere and link it like above.

Build

Simple run the following commands in the project folder. Requires no additional crates or dependencies to build.

Command Result
Debug build: cargo build You will find the executable at ./targets/debug/doit
Release build: cargo build -r You will find the executable at ./targets/release/doit

There is also a pre-commit.sh hook script that can be added to your local repo. This replicates the checks performed by the GitHub PRs. You can also simply run the script manually. You can add a sym-link to your git hooks directory:

ln -s -f ../../pre-commit.sh .git/hooks/pre-commit

Syntax Highlighting for VSCode

I've made a very simple extension for VSCode to do syntax highlighting. This extension can be found in the vscx-doit-lang/ directory.

You can local install it in VSCode by hitting Ctrl+Shift+P and searching for Developer: Install Extension from Location.... After selecting that option it will prompt you for a directory, simply navigate to the vscx-doit-lang directory and hit ok.

Contributions

The primary goal of this script is to truly follow the ideology of K.I.S.S. Simplicity and ease of use. Yes this means we lose the advantage of certain advanced features, but that's fine. If your build script needs more complexity, then there are better options out there that you can use like Makefile, NPM, Gulp, etc.

Formatting

I've included a rustfmt.toml file that I follow using VSCode and Rust-Analyser. I also use Cargo-Clippy to check for optimisations and best practices.

How to Use

In your project folder, create a file called ./do.it. This file will looked for by the program.

This script contains a very basic set of features which is made up of statements and targets.

Statements Description
exit [int] Creates an exit point that can early exit the program with a specific status integer.
my_var = 42
my_var = "Hello, world!"
my_var = 21 * my_other_var
You can create variables that are assigned from the following expression. All variables are stored as either a double or a string. They are then converted to strings when injected into script statements.
These can be defined inside either a target, or at a global scope. Variables are scoped, so a variable defined in one target will not exist in another. Global variables are shared across all targets.
$ echo "Hello, world!" Script statements are denoted by a $ symbol. Everything following the symbol until the end of the line is inserted into a C/C++ system() call. Variables can be referenced and are injected at runtime before passing the string to the system call.
# This is a comment Comments are denoted by a # symbol. Everything after it until the end of the line is considered part of the comment. Comments are added in-place to the C++ source code before compilation, but otherwise don't do anything.

Targets

Targets and scripts are the primary purpose of this. A target is defined as follows and can contain any number of comments, scripts, variables inside them.

my_target_name {
	# This is a comment inside a target
	my_var = "This is a variable that is scoped to this target only"
	$ time echo "Here is a script line" | cat
	$ echo "My variable: $my_var"
}

You can also create a single line target. When you do, the text following the : is expected to be a script as if preceded by $. Only a script is allowed on a Single Line Target.

my_target: echo "my single line target"

You can have multiple targets defined:

build {
	...
}
clean {
	...
}
run {
	...
}

Help Statements

You can also provide special help blocks that are included in the generated --help print out of your script. Only ONE help block is allowed for the global scope and for each target.

@@@
This is a special global help that describes my program
@@@

build {
@@@
This is the build target
@@@
}
clean {
	$ echo "This target does not have a help block"
}

The above script will output the following generated help:

This is a special global help that describes my program

Usage: doit <target> [args...]

TARGETS
  clean  <No help defined>
  build  This is the build target

doit's People

Contributors

flamewave000 avatar

Watchers

 avatar

doit'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.