Skip to content

shsdk/combish

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OVERVIEW

The successor bash framework to SHCF - https://github.com/shsdk/shcf

- is compiled or simply combined (hence combish or "combine" + "shell")

- "init" are all the things that comes before "lib" or can be thought of bootstrap/initialization routines/declarations
	\-> "init/01" - where all the initializations are declared
	\-> "init/10" - all core functions are here (e.g. get_machine_runner)

	why "01" and "10"? So it's possible to insert something in between.
        It's the order of being brought into the "combine" process.

	NOTE: "init/00" - is NOT to be part of combined script. Is part of "combish tooling"

- "main" - location of the main files (e.g. "main/helloworld" expected by "combish-cli build")
- "lib" - usual lib or function created
	\-> "lib/common" - for common functions, each "main" will have a common.txt (e.g. lib/helloworld/common.txt, one function per line)
	\-> subdirs as the names of each "main"
		\-> lib/helloworld
			\-> then inside, is each parameters directory (e.g. lib/helloworld) 

- common.txt - is OPTIONAL but would make your job easier if you're coding a lot of scripts that has some duplicate behaviors/functions.
  So simply put it into "lib/common" and declare from your lib application

In short:
  It's possible to create multiple scripts as each script is differentiated via own subdirectory, i.e. has it's own "init", "lib", and "main"

ORDERING

   Within "init" and "lib" are mostly function names as its filename e.g. do_this() will be in a lib/do_this.bash.inc
   BUT to facilitate ordering where another function needs to be declared first, prefix will always be ignored.

   Example:
     - lib/do_this.bash.inc
     - lib/00_do_this.bash.inc
   are valid files for "do_this()" function.

   This is an edge case as it's usually not needed for as long as the function is declared within same bash file or included.

   Strictly speaking, filename CAN be different from the actual function name, but as a rule of thumb it's better to name it
   accordingly to avoid confusing your future self when you re-read the code. What is strictly enforced is that all files
   (functions, global vars or whatever have a ".bash.inc" extension except for the common.txt.

COMBINED SCRIPT
   Located within "build" directory.

VERY SMALL SCRIPT

Framework has very low barrier to learning so you can simply run the "build" command with something like:
`combish-cli build xx`

and you would expect to get the following errors (just replace the path with yours):
```
~$ ./combish-cli build xx
ls: cannot access '/home/icasimpan/combish/init/01/xx/common.txt': No such file or directory
cat: '/home/icasimpan/combish/init/01/xx/*.bash.inc': No such file or directory
ls: cannot access '/home/icasimpan/combish/init/10/xx/common.txt': No such file or directory
cat: '/home/icasimpan/combish/init/10/xx/*.bash.inc': No such file or directory
ls: cannot access '/home/icasimpan/combish/lib/xx/common.txt': No such file or directory
cat: '/home/icasimpan/combish/lib/xx/*.bash.inc': No such file or directory
cat: /home/icasimpan/combish/main/xx/main.bash.inc: No such file or directory
/home/icasimpan/combish/build/xx.sh
```

The last line above shows the script that was created in your "build" directory:
```
/home/icasimpan/combish/build/xx.sh
```

Read "init/00/combish.bash.inc" plus trace the error above and you would understand what to do.

MODIFIERS

By default, each output script of 'combish-cli build' is standalone. But in most cases, there is a need to group scripts into say
"backups", hence a need to signify to combish that fact.

Should be declared in 'init/00/<src>/modifiers.bash.inc'

Example, for these scripts to be grouped together:
 - hello.sh
 - world.sh

add the respective files:
 - init/00/hello/modifiers.bash.inc
 - init/00/world/modifiers.bash.inc

with the value for each:
```
  script_group='example'
```

TODO: Look into possibility of adding 'common.txt' behavior in this case, add to 'combish-cli generate'

combish.bash.inc (core code) will modify the build destination accordingly.


DETACH

If you already have a lot of applications and wanted to only use one app (unbuilt), you can 'detach' it.
```
   ~$ ./combish-cli detach <src_name>
```
and it will be written to "build/detach"

example
```
   ~$ ./combish-cli detach hello
```

GENERATE

Quickly generate scaffolding for a script. Run
```
  ~$ ./combish-cli generate <src_name>
```

you can also pass a value to group the files together, remember the MODIFIERS discussed above?
```
  ~$ ./combish-cli generate <src_name> script_group='group_name'
```


IMPLEMENTATION
   Check "init/00/combish.bash.inc", it implements MOST of what is written here.

About

Successor to shcf.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published