Skip to content

Commit 420b230

Browse files
committed
remove line breaks to use editor line wraps
1 parent 0f420b1 commit 420b230

1 file changed

Lines changed: 33 additions & 80 deletions

File tree

README.md

Lines changed: 33 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,11 @@ SODA is a simple platform to help writing and executing tasks in shell script.
44

55
## How It Works
66

7-
SODA works by loading any scripts in a specific directory and calling a function
8-
passed by the command line. Only functions exposes through the builtin **task** function
9-
may be called.
7+
SODA works by loading any scripts in a specific directory and calling a function passed by the command line. Only functions exposes through the builtin **task** function may be called.
108

119
## How To Install
1210

13-
Just clone the git repo and place the *soda* file in your path (a symlinks works well to).
14-
After that, ensure you have a **$SODA_HOME** pointing to the place you clone the repo and you're
15-
done.
11+
Just clone the git repo and place the *soda* file in your path (a symlinks works well to). After that, ensure you have a **$SODA_HOME** pointing to the place you clone the repo and you're done.
1612

1713
## How To Use
1814

@@ -22,11 +18,9 @@ Create a *~/.soda* directory with the following structure:
2218
* _config_ - directory to put the configuration files organized by namespaces
2319
* Any other directory you like, still organized by namespaces
2420

25-
You can also use the same directory you install soda without configure the user directory. You can
26-
access any file in that directories by using the **exists** function.
21+
You can also use the same directory you install soda without configure the user directory. You can access any file in that directories by using the **exists** function.
2722

28-
Inside *scripts*, any function in any script present in *scripts/common* and exposed through
29-
**task** can be invoked:
23+
Inside *scripts*, any function in any script present in *scripts/common* and exposed through **task** can be invoked:
3024

3125
task "git-open" "Creates a new branch off master"
3226
git_open() {
@@ -39,19 +33,15 @@ Inside *scripts*, any function in any script present in *scripts/common* and exp
3933

4034
$ soda git-open work
4135

42-
This will call the *git_open* function passing *work* as the arguments. By convention, you
43-
may call a function with underscores replacing them by hyphens. To execute the task without
44-
arguments, just use `soda git-open`.
36+
This will call the *git_open* function passing *work* as the arguments. By convention, you may call a function with underscores replacing them by hyphens. To execute the task without arguments, just use `soda git-open`.
4537

4638
To see the program usage, type `soda`, `soda help` or `soda --help`.
4739

4840
## Task Namespaces
4941

50-
The namespaces are simply directories in _scripts_. By default, the *common* and *soda* namespaces
51-
are always imported. You can include other namespaces using the **import** function.
42+
The namespaces are simply directories in _scripts_. By default, the *common* and *soda* namespaces are always imported. You can include other namespaces using the **import** function.
5243

53-
Namespaces are useful if you have a set of scripts that you should use only on specific cases. (It
54-
also keeps your scripts organized.)
44+
Namespaces are useful if you have a set of scripts that you should use only on specific cases. (It also keeps your scripts organized.)
5545

5646
# Example: script inside ~/.soda/scripts/git
5747

@@ -80,15 +70,11 @@ You can call any task in *git* namespace using a **"."**:
8070

8171
$ soda git.push
8272

83-
The **"."** indicates that namespace is the first part and task is the second part. To see a help
84-
message for only one namespace, use `soda help NAMESPACE` (additionally, you can place a `info` file
85-
in the scripts folder for a namespace to make its contents appear in the help message).
73+
The **"."** indicates that namespace is the first part and task is the second part. To see a help message for only one namespace, use `soda help NAMESPACE` (additionally, you can place a `info` file in the scripts folder for a namespace to make its contents appear in the help message).
8674

8775
## Task Parameters
8876

89-
If you need to pass a set of parameters, you can use --OPTION_NAME in case of a boolean option or
90-
--OPTION_NAME=OPTION_VALUE. The parameters will be translated replacing hyphens with underscores
91-
(but ignoring the prefix **--**) **with upper case**.
77+
If you need to pass a set of parameters, you can use --OPTION_NAME in case of a boolean option or --OPTION_NAME=OPTION_VALUE. The parameters will be translated replacing hyphens with underscores (but ignoring the prefix **--**) **with upper case**.
9278

9379
$ soda --my-option=test
9480

@@ -97,8 +83,7 @@ If you need to pass a set of parameters, you can use --OPTION_NAME in case of a
9783
# some code
9884
fi
9985

100-
To register a parameter in the program usage, use the *parameter* function (for more details, see
101-
the documentation bellow). The registered parameters will also be available for bash completion.
86+
To register a parameter in the program usage, use the *parameter* function (for more details, see the documentation bellow). The registered parameters will also be available for bash completion.
10287

10388
Keep in mind that **any** parameter will be converted to a variable (even those not exposed).
10489

@@ -117,8 +102,7 @@ The builtin events are:
117102

118103
* **start** - before the task execution
119104
* **finish** - after the task execution
120-
* **fail** *(exit code)* - when a command fails to execute (broadcasted by *execute* and *check*
121-
functions)
105+
* **fail** *(exit code)* - when a command fails to execute (broadcasted by *execute* and *check* functions)
122106

123107
## Quick Tasks
124108

@@ -137,10 +121,7 @@ Any directory in the form `bin/$NAMESPACE` in both `$SODA_HOME` or `$SODA_USER_H
137121

138122
## Bash Completion
139123

140-
SODA supports bash completion by importing all namespaces and searching for defined parameters
141-
and tasks. To enable bash completion, use the file **soda-bash-completion** (you can source it,
142-
copy to */etc/bash_completion.d/* or using your preferred way). The default bash completion proposes
143-
tasks and parameters.
124+
SODA supports bash completion by importing all namespaces and searching for defined parameters and tasks. To enable bash completion, use the file **soda-bash-completion** (you can source it, copy to */etc/bash_completion.d/* or using your preferred way). The default bash completion proposes tasks and parameters.
144125

145126
$ soda he[TAB]
146127
$ soda help
@@ -163,8 +144,7 @@ Alternatively, you can use the **suggest** function to map the bash completion f
163144
echo "bar"
164145
}
165146

166-
If a parameter is passed after the task declaration in command line, the suggestions will be only
167-
the parameters for the task namespace.
147+
If a parameter is passed after the task declaration in command line, the suggestions will be only the parameters for the task namespace.
168148

169149
# namespace my-namespace
170150

@@ -177,44 +157,32 @@ the parameters for the task namespace.
177157
$ soda my-namespace.my-task --[TAB]
178158
$ soda my-namespace.my-task --option
179159

180-
It is important to remember that logs and event broadcasting are disabled while SODA is in bash
181-
completion mode.
160+
It is important to remember that logs and event broadcasting are disabled while SODA is in bash completion mode.
182161

183162
## Configuration
184163

185-
Every namespace has it own configuration dir in $SODA_USER_HOME/config/NAMESPACE. Any configuration
186-
file will be loaded in that directory at namespace import **before** loading script files.
164+
Every namespace has it own configuration dir in $SODA_USER_HOME/config/NAMESPACE. Any configuration file will be loaded in that directory at namespace import **before** loading script files.
187165

188-
You can configure **soda** namespace through a **$SODA_USER_HOME/conf/soda/soda.conf** file (or any
189-
other name but inside that directory). The supported properties are:
166+
You can configure **soda** namespace through a **$SODA_USER_HOME/conf/soda/soda.conf** file (or any other name but inside that directory). The supported properties are:
190167

191168
* **LOG_FILE** - The log file (defaults to *$SODA_HOME/log/soda.log*)
192-
* **SODA_NAMESPACE_DELIMITER** - The namespace delimiter (defaults to **.**). Changing this also
193-
affects the bash completion
194-
* **SODA_TASK_BASH_COMPLETION_SUFFIX** - The suffix to build the function for custom bash completion
195-
(defaults to *_bash_completion*)
169+
* **SODA_NAMESPACE_DELIMITER** - The namespace delimiter (defaults to **.**). Changing this also affects the bash completion
170+
* **SODA_TASK_BASH_COMPLETION_SUFFIX** - The suffix to build the function for custom bash completion (defaults to *_bash_completion*)
196171
* **SODA_FILE_LOG_PATTERN** - The pattern to format logs that goes in *LOG_FILE*
197172
* **SODA_CONSOLE_LOG_PATTERN** - The pattern to format logs that goes in console
198173
* **SODA_FUNCTION_NAME_LENGTH** - The max length to format the function name in the help usage
199174
* **SODA_PARAMETER_NAME_LENGTH** - The max length to format the parameter names in the help usage
200-
* **SODA_PARAMETER_NAMESPACE_LENGTH** - The max length to format the parameter namespace in the help
201-
usage
202-
* **SODA_DEFAULT_RESOURCE_DIR** - the default directory to search for resources (defaults to
203-
*resources*)
175+
* **SODA_PARAMETER_NAMESPACE_LENGTH** - The max length to format the parameter namespace in the help usage
176+
* **SODA_DEFAULT_RESOURCE_DIR** - the default directory to search for resources (defaults to *resources*)
204177
* **SODA_TASK_OPTIONAL_PREFIX** - the optional prefix to map a task function (defaults to *do_*)
205178

206-
Remember that parameters are converted to upper case, so you can call `soda --log-file=path/to/file`
207-
and the *$LOG_FILE* variable will be set to that value.
179+
Remember that parameters are converted to upper case, so you can call `soda --log-file=path/to/file` and the *$LOG_FILE* variable will be set to that value.
208180

209-
The parameter **SODA_TASK_OPTIONAL_PREFIX** is very usefull in case of tasks with a name already
210-
defined by another function or name (*kill* or *status*, for example). To avoid conflicts, prefix
211-
the function with the SODA_TASK_OPTIONAL_PREFIX value (*do_kill*, *do_status*, ...).
181+
The parameter **SODA_TASK_OPTIONAL_PREFIX** is very usefull in case of tasks with a name already defined by another function or name (*kill* or *status*, for example). To avoid conflicts, prefix the function with the SODA_TASK_OPTIONAL_PREFIX value (*do_kill*, *do_status*, ...).
212182

213183
## Logging
214184

215-
To log something, just call the **log** function passing the category and message (optionally, you
216-
can pass a color for showing in console). There are some aliases for calling log with a predefined
217-
category:
185+
To log something, just call the **log** function passing the category and message (optionally, you can pass a color for showing in console). There are some aliases for calling log with a predefined category:
218186

219187
* **log_debug** - uses the DEBUG category
220188
* **log_info** - uses the INFO category
@@ -235,20 +203,15 @@ If you want to use another log system (a *syslog* or another) just define a **lo
235203

236204
## Builtin functions
237205

238-
The builtin functions are present in *scripts/soda* dir and the *scripts/core.sh*, the
239-
most significant are listed below:
206+
The builtin functions are present in *scripts/soda* dir and the *scripts/core.sh*, the most significant are listed below:
240207

241208
### task (function_name, [function_args], [description])
242209

243-
Register the given function as a task and enables invoking it. You may pass the function
244-
args in *$function_name*. If a description is given, expose the given function in the program usage
245-
and register it for autocompletion.
210+
Register the given function as a task and enables invoking it. You may pass the function args in *$function_name*. If a description is given, expose the given function in the program usage and register it for autocompletion.
246211

247212
### parameter (parameter_name, [value_name] ,[default_value], description)
248213

249-
Register the given parameter and returns indicating if the parameter was given. The parameter value
250-
is accessible through the variable $parameter_name in upper case with hyphens replaced by
251-
underscores.
214+
Register the given parameter and returns indicating if the parameter was given. The parameter value is accessible through the variable $parameter_name in upper case with hyphens replaced by underscores.
252215

253216
parameter "help" "Prints this help message" && {
254217
usage
@@ -260,19 +223,15 @@ underscores.
260223

261224
### exists ([type] path)
262225

263-
Checks if the file $SODA_USER_HOME/$type/$NAMESPACE/$path exists using the namespace of the invoked
264-
task or imported namespace. The file path will be stored in the $FILE variable. If the *type* is not
265-
passed then **resources** will be used.
226+
Checks if the file $SODA_USER_HOME/$type/$NAMESPACE/$path exists using the namespace of the invoked task or imported namespace. The file path will be stored in the $FILE variable. If the *type* is not passed then **resources** will be used.
266227

267228
exists config "my-config.conf" && {
268229
source $FILE
269230
}
270231

271232
### resource ([type] path)
272233

273-
Returns the file $SODA_USER_HOME/$type/$NAMESPACE/$path using the namespace of the invoked task or
274-
imported namespace without checking if the file exists. If the *type* is not passed then
275-
**resources** will be used. For use with the **config** type, use the `config` builtin function.
234+
Returns the file $SODA_USER_HOME/$type/$NAMESPACE/$path using the namespace of the invoked task or imported namespace without checking if the file exists. If the *type* is not passed then **resources** will be used. For use with the **config** type, use the `config` builtin function. The `config` function redirects to the resource function using *config* as the first parameter and the given parameter as the second parameter.
276235

277236
### invoke (description, function_name)
278237

@@ -288,13 +247,11 @@ Asks user about something and indicates if the answer is **yes** or **no**.
288247

289248
### check (description)
290249

291-
Checks if the previous command returned successfully and logs the result using the given
292-
description.
250+
Checks if the previous command returned successfully and logs the result using the given description.
293251

294252
### execute (description, command, [*args])
295253

296-
Executes a command and checks if it was sucessfull. The output will be stored in the variable
297-
*$LAST_EXECUTION_OUTPUT* and the result will be .
254+
Executes a command and checks if it was sucessfull. The output will be stored in the variable *$LAST_EXECUTION_OUTPUT* and the result will be .
298255

299256
execute "Pushing commits" git push
300257
# outputs according to exit code:
@@ -303,8 +260,7 @@ Executes a command and checks if it was sucessfull. The output will be stored in
303260

304261
### input (description, variable, [default_value])
305262

306-
Asks the user to input a value. The value will be stored in the indicated variable. If the variable
307-
name is in upper case and is already set, the prompt will be skipped.
263+
Asks the user to input a value. The value will be stored in the indicated variable. If the variable name is in upper case and is already set, the prompt will be skipped.
308264

309265
input "Server address" "SERVER" "localhost"
310266
input "User name" "USER_NAME" "$(whoami)"
@@ -313,9 +269,7 @@ name is in upper case and is already set, the prompt will be skipped.
313269

314270
### choose (description, variable, *options)
315271

316-
Asks user to choose a value from a list of options and stores the 0-based index
317-
of the selected value and the label in the $variable_label var. If the variable name
318-
is in upper case and is already set, the prompt will be skipped.
272+
Asks user to choose a value from a list of options and stores the 0-based index of the selected value and the label in the $variable_label var. If the variable name is in upper case and is already set, the prompt will be skipped.
319273

320274
choose "Server Type" "SERVER_TYPE" "Production" "Development"
321275

@@ -327,8 +281,7 @@ Maps the given function as the bash completion function to the given tasks.
327281

328282
### when (event_name subscribers...)
329283

330-
Subscribe the given functions to the specified event name. The subscribers should be notified using
331-
the *broadcast* function.
284+
Subscribe the given functions to the specified event name. The subscribers should be notified using the *broadcast* function.
332285

333286
### broadcast (event_name [args...])
334287

0 commit comments

Comments
 (0)