Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.
/ ellipsis-compiler Public archive

Configuration file compiler - [ Ellipsis extension ]

License

Notifications You must be signed in to change notification settings

ellipsis/ellipsis-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

78 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ellipsis-compiler Build Status Documentation status Latest tag Gitter chat

Configuration file compiler

Ellipsis-Compiler is a compiler for configuration files. It makes it possible to use logic in any config file. This allows you to make dynamic configurations, even if this is normally not supported.

Features

  • Create dynamic and smart configuration files
  • Supports virtualy all types of config files
  • Addapts to your needs
  • Does not break syntax highlighting/checking
  • Cleans up existing config files
  • Verry portable
  • Ellipsis integration

Install

Requirements: Ellipsis

# With ellipsis installed
$ ellipsis install ellipsis-compiler

# Without ellipsis installed
$ curl -Ls ellipsis.sh | PACKAGES='ellipsis-compiler' sh

The .ellipsis/bin folder should be added to your path. If it isn't you will need to symlink .ellipsis/bin/ellipsis-compiler to a folder that is in your path.

Usage

Basic usage:

$ ellipsis-compiler $input-file $output-file

If the output file is omitted, $input-file.out will be used.

Syntax

Ellipsis-Compiler uses specially formatted comments for its syntax. This will preserve syntax-highlighting/checks and makes it possible to have files that also work if they aren't compiled.

By default the # symbol is used to indicate comments, but this can be altered by setting the $EC_COMMENT variable. Lines that need to be interpreted by the compiler are indicated with a prompt like string _>. This string can be altered by setting the $EC_PROMPT variable.

include (include_raw)

Include a file, or include a file without processing (include_raw).

#_> include test_file.econf
#_> include_raw raw_config.conf

Output will include the processed content of test_file.econf and the raw content of raw_config.conf.

if (then, else, elif)

Use the if,then,else/elif construction to alter compilation output. The test itself is just bash (with all it's possibilities).

## Use default file if test_file is not available
#_> if [ ! -f test_file ]; then
conf.settings=default_file
#_> else
conf.settings=test_file
#_> fi
raw

Perform a raw shell command. Output can be redirected to $target to add it to the compiled file.

Try to avoid the raw command, it is only provided for really funky stuff. Your task not that funky? Please consider to provide a pull request for your missing feature or submit an issue.

## Use the current kernel number in your config file
#_> raw echo "config.kernel=$(uname -r)" >> "$target"
write (>)

Write a string to the output file.

## Writes '#_> command' to the output file
#_> write #_> command

## Using the short form, ideal for indenting lines without introducing
## whitespace infront of the lines.
#_> if [ ! -f test_file ]; then
#_>     > conf.settings=default_file
#_> else
#_>     > conf.settings=test_file
#_> fi
msg

Print a message to stdout, to inform a user about something.

## Prints 'Hello world' to stdout
#_> msg Hello world
fail

Stop compilation, log and display the given message.

## If test_file exists it is used in the config, else compilation will fail
#_> if [ ! -f test_file ]; then
#_>     fail Could not compile, 'test_file' missing!
#_> else
        conf.settings=test_file
#_> fi
warn

Show and log a warning message.

## If test_file exists it is used in the config, else a warning will be shown
#_> if [ ! -f test_file ]; then
#_>     warn 'conf.settings' not set, 'test_file' not available.
#_> else
        conf.settings=test_file
#_> fi
mode

Change the default file mode. The last encountered mode setting will be used. The mode can still be forced at compile time using the $EC_MODE variable.

## Write the file as executable
#_> mode 755

## Four digit modes are also allowed
#_> mode 0755

Development

Pull requests welcome! New code should follow the existing style (and ideally include tests).

Suggest a feature or report a bug? Create an issue!

Author(s)

You can thank these people for all there hard work.

License

Ellipsis-compiler is open-source software licensed under the MIT license.