Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.
Ralf Kilian edited this page Jun 17, 2024 · 6 revisions

TaSp TaSp logo

Table of contents


Indentation methods

Usually, operating systems provide powerful command line tools (e. g. sed on Unix-like systems) that also allow to accelerate such a process, but these often are quite extensive (due to a lot of features) and may require some shell experience.

For example, if you want to use sed (details can be found here) to replace every tab with four spaces inside all files with the file extension cfg that are located in the directory /tmp/foobar and all of its sub-directories, you could either write a simple shell script like this

#!/bin/bash

for cfg_file in $(find /tmp/foobar -type f | grep "\.cfg$"); do
    cat "$cfg_file" | sed -e "s/\t/    /g" > /tmp/sed_replace.tmp
    mv -f /tmp/sed_replace.tmp "$cfg_file"
done

or convert that script into a single command line:

$ find /tmp/foobar -type f -regex ".*\.cfg$" -exec sed -i "s/\t/    /g" {} +

The TaSp project provides the replace component which is a command line tool indeed, but its main purpose is to get a consistent indentation method inside files, so it only requires a few simple command-line arguments for that purpose:

$ ./tasp-replace.py -d /tmp/foobar -r -f cfg --overwrite -m spaces -s 4

Top

Consistent indentation

After getting a consistent indentation method (as described inside the paragraph above), the files may still be messed up like this sample config file:

server myserver {
   ip_address    192.168.1.1;  # IP address
  name   myserver.foo.bar;   # host name
      type    foobar;  # server type
     description    foobar server;  # server description
}

The TaSp project also provides the indent component which also requires a few simple command-line arguments, only.

For example, to indent the messed up lines with four leading spaces and the items per line using a padding of twenty spaces, the command would look like this

$ ./tasp-indent.py -d /tmp/foobar -r -f cfg --overwrite -s 4 -p 20

and change the indentation as follows:

server myserver {
    ip_address          192.168.1.1;        # IP address
    name                myserver.foo.bar;   # host name
    type                foobar;             # server type
    description         foobar server;      # server description
}

Top

Components

TaSp Indent

The indent component consistently indents messed up files. Details can be found above.

TaSp Replace

The replace component replaces tabs with spaces (or vice versa) for a consistent indentation method inside files. Details can also be found above.

Top

End-of-life

Dead end signOn April 2018 the project was officially discontinued.

Initially developed for fixing the indentation of terribly messed up configs of a common monitoring software at work, TaSp has lost its importance after that software has been replaced by a different and more decent solution.

Hence, there was no more reason to continue with the development.

Feel free to fork!

Top

Clone this wiki locally