diff options
-rw-r--r-- | README.html | 379 | ||||
-rw-r--r-- | README.org | 169 |
2 files changed, 504 insertions, 44 deletions
diff --git a/README.html b/README.html index 227c7f6..72df0fc 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> -<!-- 2018-09-20 Thu 20:23 --> +<!-- 2018-09-23 Sun 00:02 --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>‎</title> @@ -232,21 +232,35 @@ for the JavaScript code in this tag. <h2>Table of Contents</h2> <div id="text-table-of-contents"> <ul> -<li><a href="#org030e7a3">1. ck</a></li> -<li><a href="#org64b2495">2. build it</a> +<li><a href="#org0688d9b">1. ck</a></li> +<li><a href="#org57f210d">2. build it</a> <ul> -<li><a href="#org1ba4a90">2.1. requirements</a></li> -<li><a href="#orga58ac2a">2.2. compiler</a></li> -<li><a href="#org85b9108">2.3. make</a></li> +<li><a href="#org54a9881">2.1. requirements</a></li> +<li><a href="#org9696939">2.2. compiler</a></li> +<li><a href="#orgea98eb4">2.3. make</a></li> </ul> </li> -<li><a href="#orgc667e72">3. for devs</a> +<li><a href="#orgaa6c440">3. for devs</a> <ul> -<li><a href="#org3fafd79">3.1. make</a></li> -<li><a href="#orge454e00">3.2. tests</a> +<li><a href="#org2cde047">3.1. make</a></li> +<li><a href="#org3df84a7">3.2. tests</a> <ul> -<li><a href="#orgb5a537f">3.2.1. run tests</a></li> -<li><a href="#orgb4ad06c">3.2.2. test suite</a></li> +<li><a href="#org5f2c899">3.2.1. run tests</a></li> +<li><a href="#orgab7d73d">3.2.2. test suite</a></li> +</ul> +</li> +</ul> +</li> +<li><a href="#org2eea1a2">4. manual</a> +<ul> +<li><a href="#org6a7b3d6">4.1. ck configuration</a></li> +<li><a href="#org975adc8">4.2. Actions</a> +<ul> +<li><a href="#org31574ed">4.2.1. init</a></li> +<li><a href="#org3d938c1">4.2.2. add</a></li> +<li><a href="#org52062dd">4.2.3. list</a></li> +<li><a href="#org3658d37">4.2.4. search</a></li> +<li><a href="#org840d95e">4.2.5. edit</a></li> </ul> </li> </ul> @@ -255,8 +269,8 @@ for the JavaScript code in this tag. </div> </div> <p align="center"><img src="res/logo.png" width="30%" height="30%" /></p> -<div id="outline-container-org030e7a3" class="outline-2"> -<h2 id="org030e7a3"><span class="section-number-2">1</span> ck</h2> +<div id="outline-container-org0688d9b" class="outline-2"> +<h2 id="org0688d9b"><span class="section-number-2">1</span> ck</h2> <div class="outline-text-2" id="text-1"> <p> <b>The Config Keeper</b> @@ -264,12 +278,12 @@ for the JavaScript code in this tag. </div> </div> -<div id="outline-container-org64b2495" class="outline-2"> -<h2 id="org64b2495"><span class="section-number-2">2</span> build it</h2> +<div id="outline-container-org57f210d" class="outline-2"> +<h2 id="org57f210d"><span class="section-number-2">2</span> build it</h2> <div class="outline-text-2" id="text-2"> </div> -<div id="outline-container-org1ba4a90" class="outline-3"> -<h3 id="org1ba4a90"><span class="section-number-3">2.1</span> requirements</h3> +<div id="outline-container-org54a9881" class="outline-3"> +<h3 id="org54a9881"><span class="section-number-3">2.1</span> requirements</h3> <div class="outline-text-3" id="text-2-1"> <ul class="org-ul"> <li>clang (llvm) or gcc (gnu)</li> @@ -279,8 +293,8 @@ for the JavaScript code in this tag. </div> </div> -<div id="outline-container-orga58ac2a" class="outline-3"> -<h3 id="orga58ac2a"><span class="section-number-3">2.2</span> compiler</h3> +<div id="outline-container-org9696939" class="outline-3"> +<h3 id="org9696939"><span class="section-number-3">2.2</span> compiler</h3> <div class="outline-text-3" id="text-2-2"> <p> By default I use clang, if you want to use gcc just @@ -289,19 +303,19 @@ edit the <code>CMakeLists.txt</code> file and change <code>clang</code> to <code </div> </div> -<div id="outline-container-org85b9108" class="outline-3"> -<h3 id="org85b9108"><span class="section-number-3">2.3</span> make</h3> +<div id="outline-container-orgea98eb4" class="outline-3"> +<h3 id="orgea98eb4"><span class="section-number-3">2.3</span> make</h3> <div class="outline-text-3" id="text-2-3"> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">clone the repo</span> > cd ~/code; git clone https://gitlab.com/grm-grm/ck -<span style="color: #656565;"># </span><span style="color: #757575;">make a build directory and enter it</span> -> mkdir ~/ck_build; <span style="color: #528fd1;">cd</span> ~/ck_build; -<span style="color: #656565;"># </span><span style="color: #757575;">run cmake</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">make a build directory and enter it</span> +> mkdir ~/ck_build; <span style="color: #ff0066;">cd</span> ~/ck_build; +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run cmake</span> > cmake ~/code/ck -<span style="color: #656565;"># </span><span style="color: #757575;">run make</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run make</span> > make -<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run ck</span> > ./ck </pre> </div> @@ -309,35 +323,35 @@ edit the <code>CMakeLists.txt</code> file and change <code>clang</code> to <code </div> </div> -<div id="outline-container-orgc667e72" class="outline-2"> -<h2 id="orgc667e72"><span class="section-number-2">3</span> for devs</h2> +<div id="outline-container-orgaa6c440" class="outline-2"> +<h2 id="orgaa6c440"><span class="section-number-2">3</span> for devs</h2> <div class="outline-text-2" id="text-3"> </div> -<div id="outline-container-org3fafd79" class="outline-3"> -<h3 id="org3fafd79"><span class="section-number-3">3.1</span> make</h3> +<div id="outline-container-org2cde047" class="outline-3"> +<h3 id="org2cde047"><span class="section-number-3">3.1</span> make</h3> <div class="outline-text-3" id="text-3-1"> <p> Just build with address sanitizer enabled like so: llvm has better asan than gcc, so I use that. </p> <div class="org-src-container"> -<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">clone the repo</span> > cd ~/code; git clone https://gitlab.com/grm-grm/ck -<span style="color: #656565;"># </span><span style="color: #757575;">make a build directory and enter it</span> -> mkdir ~/ck_build; <span style="color: #528fd1;">cd</span> ~/ck_build; -<span style="color: #656565;"># </span><span style="color: #757575;">run cmake</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">make a build directory and enter it</span> +> mkdir ~/ck_build; <span style="color: #ff0066;">cd</span> ~/ck_build; +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run cmake</span> > cmake ~/code/ck -DCK_ASAN=ON -<span style="color: #656565;"># </span><span style="color: #757575;">run make</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run make</span> > make -<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">run ck</span> > ./ck </pre> </div> </div> </div> -<div id="outline-container-orge454e00" class="outline-3"> -<h3 id="orge454e00"><span class="section-number-3">3.2</span> tests</h3> +<div id="outline-container-org3df84a7" class="outline-3"> +<h3 id="org3df84a7"><span class="section-number-3">3.2</span> tests</h3> <div class="outline-text-3" id="text-3-2"> <p> The testing "suite" is a bash script that runs regression @@ -347,8 +361,8 @@ under <code>unit/</code> directory and test the code. </p> </div> -<div id="outline-container-orgb5a537f" class="outline-4"> -<h4 id="orgb5a537f"><span class="section-number-4">3.2.1</span> run tests</h4> +<div id="outline-container-org5f2c899" class="outline-4"> +<h4 id="org5f2c899"><span class="section-number-4">3.2.1</span> run tests</h4> <div class="outline-text-4" id="text-3-2-1"> <p> Simply go to the build dir and type. @@ -360,8 +374,8 @@ Simply go to the build dir and type. </div> </div> -<div id="outline-container-orgb4ad06c" class="outline-4"> -<h4 id="orgb4ad06c"><span class="section-number-4">3.2.2</span> test suite</h4> +<div id="outline-container-orgab7d73d" class="outline-4"> +<h4 id="orgab7d73d"><span class="section-number-4">3.2.2</span> test suite</h4> <div class="outline-text-4" id="text-3-2-2"> <div class="org-src-container"> <pre class="src src-sh">$ ./check_ck -h @@ -380,9 +394,286 @@ flags: </div> </div> </div> +<div id="outline-container-org2eea1a2" class="outline-2"> +<h2 id="org2eea1a2"><span class="section-number-2">4</span> manual</h2> +<div class="outline-text-2" id="text-4"> +<p> +ck's goal is to assist with the configuration file management. +To that end it tries to provides a cli interface that is pretty straight-forward +and intuitive. +</p> + +<p> +Example usage: +</p> +<div class="org-src-container"> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">initialize new ck</span> +$ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #E6DB74; font-weight: bold;">\</span> + /path_to/the_secret/directory + +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">add emacs configs</span> +<span style="color: #6A6D70;">## </span><span style="color: #6A6D70;">primary config</span> +$ ck add emacs ~/.emacs.d/orgconf.org -p +<span style="color: #6A6D70;">## </span><span style="color: #6A6D70;">secret config, with passwords and naughty words</span> +$ ck add emacs ~/.emacs.d/accounts.org -s +<span style="color: #6A6D70;">## </span><span style="color: #6A6D70;">and another one for emacs</span> +$ ck add emacs ~/.emacs.d/init.el + +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">add tmux config</span> +$ ck add tmux ~/.tmux.conf -p + +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list the configs</span> +$ ck list tree +$ ck list paths -t lisp +$ ck list programs -t python + +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">search the configs</span> +$ ck search search-term +$ ck search <span style="color: #E6DB74;">"\"search term with spaces\""</span> +$ ck search <span style="color: #E6DB74;">"\("</span> <span style="color: #6A6D70;">#</span><span style="color: #6A6D70;">escape symbols</span> +</pre> +</div> + +<p> +The first command after typing <b>ck</b> is the action you wish to perform. Actions are +a very important concept of ck. With an action you can initialize <b>ck</b>, add/move/delete +configuration files to it, edit them, list them in various ways and search in their content. +</p> + +<p> +Actions expect their arguments in the order specified below. This is done to reduce the amount +of flags one has to pass to ck. +</p> +</div> + +<div id="outline-container-org6a7b3d6" class="outline-3"> +<h3 id="org6a7b3d6"><span class="section-number-3">4.1</span> ck configuration</h3> +<div class="outline-text-3" id="text-4-1"> +<p> +ck uses sqlite to index the configuration files. The init +action creates a <b>.ck</b> directory (under $HOME) +in witch the <b>ckrc</b> and the <b>ckdb</b> reside. The first one contains +the two directories described above while the other one is the +sqlite db. +</p> + +<p> +One can have multiple config directories with different configurations +each. +</p> + +<p> +Using the special keyword <b>config</b> (or <b>conf</b> or <b>c</b> or <b>-c</b>) you can set the path +in which ck will search for the <b>.ck</b> directory. +</p> + +<p> +You can prefix every action with this and ck will use the configuration +directory of your choice. +</p> + +<p> +Usage: +</p> +<div class="org-src-container"> +<pre class="src src-sh">$ ck config ~/ ... <span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">the default behaviour</span> + +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">/someplace/else must exist or</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">the action following it must be init</span> +$ ck conf /someplace/else ... + +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">same thing</span> +$ ck c /someplace/else ... +$ ck -c /someplace/else ... +</pre> +</div> +</div> +</div> + +<div id="outline-container-org975adc8" class="outline-3"> +<h3 id="org975adc8"><span class="section-number-3">4.2</span> Actions</h3> +<div class="outline-text-3" id="text-4-2"> +</div> +<div id="outline-container-org31574ed" class="outline-4"> +<h4 id="org31574ed"><span class="section-number-4">4.2.1</span> init</h4> +<div class="outline-text-4" id="text-4-2-1"> +<p> +or i or -i +</p> + +<p> +init takes exactly 2 arguments. +</p> + +<ul class="org-ul"> +<li><b>config<sub>dir</sub></b>: where all the configs will live</li> +<li><b>secret<sub>dir</sub></b>: where all the secret configs will live</li> +</ul> + +<p> +Use init to initialize a new ck database. +</p> + +<p> +Usage: +</p> +<div class="org-src-container"> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">initialize new ck</span> +$ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #E6DB74; font-weight: bold;">\</span> + /path_to/the_secret/directory +</pre> +</div> +</div> +</div> + +<div id="outline-container-org3d938c1" class="outline-4"> +<h4 id="org3d938c1"><span class="section-number-4">4.2.2</span> add</h4> +<div class="outline-text-4" id="text-4-2-2"> +<p> +or a or -a +</p> + +<p> +Add takes 2 to 4 arguments. +</p> + +<ul class="org-ul"> +<li><b>program<sub>name</sub></b>: the name of the program you add a config to</li> +<li><b>config<sub>path</sub></b>: the path to the config</li> +<li>Optional: (order doesn't matter) +<ul class="org-ul"> +<li><b>-p</b>: the config will be the primary (relevant on edit below)</li> +<li><b>-s</b>: the config will be stored in the secret<sub>dir</sub></li> +</ul></li> +</ul> + +<p> +Use add to add a new config for ck to keep track of. +</p> + +<p> +Keep in mind: +</p> +<ul class="org-ul"> +<li>The config has to exist</li> +<li>If you are adding a config to a program already existing in ckdb make +sure to use the same name</li> +<li>Each program can have only one primary config</li> +</ul> + +<p> +Usage: +</p> +<div class="org-src-container"> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">add config to ck</span> +$ ck add program_name config_path [-s] [-p] +</pre> +</div> +</div> +</div> + +<div id="outline-container-org52062dd" class="outline-4"> +<h4 id="org52062dd"><span class="section-number-4">4.2.3</span> list</h4> +<div class="outline-text-4" id="text-4-2-3"> +<p> +or ls or l or -l +</p> + +<p> +List can show the <b>paths</b> or the <b>programs</b> that ck keeps track of. +With the flag <b>-t</b> and then one of the follwing types one can change +the way the list is printed: +</p> +<ul class="org-ul"> +<li><b>plain</b>: simple listing (default)</li> +<li><b>python</b>: print like a python list</li> +<li><b>lisp</b>: print like a lisp list</li> +</ul> + +<p> +Using the keyword <b>tree</b> ck can list the configurations under their +corresponding program. +</p> + +<div class="org-src-container"> +<pre class="src src-C"><span style="color: #6A6D70;">/* </span><span style="color: #6A6D70;">TODO: show primary and secret atributes </span><span style="color: #6A6D70;">*/</span> +</pre> +</div> +<p> +Usage: +</p> +<div class="org-src-container"> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list tree structure</span> +$ ck list tree +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list paths in python</span> +$ ck l paths -t python +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">list programs in lisp</span> +$ ck ls programs -t lisp +</pre> +</div> +</div> +</div> + +<div id="outline-container-org3658d37" class="outline-4"> +<h4 id="org3658d37"><span class="section-number-4">4.2.4</span> search</h4> +<div class="outline-text-4" id="text-4-2-4"> +<p> +or s or -s +</p> + +<p> +Perform infile grep in all the configurations ck keeps track of. +</p> + +<p> +Takes one argument, the <b>search-term</b>. +</p> + +<p> +To search for terms with spaces you have to put them in escaped quotes. +To search for special symbols you have to enclose them in quotes and escape them. +</p> + +<p> +Usage: +</p> +<div class="org-src-container"> +<pre class="src src-sh"><span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">search for parenthesis</span> +$ ck search <span style="color: #E6DB74;">"\("</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">search term with spaces</span> +$ ck search <span style="color: #E6DB74;">"\"This is a space\""</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">both</span> +$ ck search <span style="color: #E6DB74;">"\"(add 2 4)\""</span> +<span style="color: #6A6D70;"># </span><span style="color: #6A6D70;">and a normal one</span> +$ ck search alias +</pre> +</div> +</div> +</div> + +<div id="outline-container-org840d95e" class="outline-4"> +<h4 id="org840d95e"><span class="section-number-4">4.2.5</span> edit</h4> +<div class="outline-text-4" id="text-4-2-5"> +<p> +or e or -e +<code>~--WIP--~</code> +Currently edit can only edit the primary config of a program. +</p> + +<p> +To do it use: +</p> +<div class="org-src-container"> +<pre class="src src-sh">$ ck edit program_name +</pre> +</div> +</div> +</div> +</div> +</div> </div> <div id="postamble" class="status"> -<p class="date">Created: 2018-09-20 Thu 20:23</p> +<p class="date">Created: 2018-09-23 Sun 00:02</p> <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> </div> </body> @@ -68,3 +68,172 @@ flags: use it if the tests fail -h, --help, * print this #+END_SRC +* manual +ck's goal is to assist with the configuration file management. +To that end it tries to provides a cli interface that is pretty straight-forward +and intuitive. + +Example usage: +#+BEGIN_SRC sh + # initialize new ck + $ ck init /path_to/where_you_want/your_configs/to_be \ + /path_to/the_secret/directory + + # add emacs configs + ## primary config + $ ck add emacs ~/.emacs.d/orgconf.org -p + ## secret config, with passwords and naughty words + $ ck add emacs ~/.emacs.d/accounts.org -s + ## and another one for emacs + $ ck add emacs ~/.emacs.d/init.el + + # add tmux config + $ ck add tmux ~/.tmux.conf -p + + # list the configs + $ ck list tree + $ ck list paths -t lisp + $ ck list programs -t python + + # search the configs + $ ck search search-term + $ ck search "\"search term with spaces\"" + $ ck search "\(" #escape symbols +#+END_SRC + +The first command after typing *ck* is the action you wish to perform. Actions are +a very important concept of ck. With an action you can initialize *ck*, add/move/delete +configuration files to it, edit them, list them in various ways and search in their content. + +Actions expect their arguments in the order specified below. This is done to reduce the amount +of flags one has to pass to ck. + +** ck configuration +ck uses sqlite to index the configuration files. The init +action creates a *.ck* directory (under $HOME) +in witch the *ckrc* and the *ckdb* reside. The first one contains +the two directories described above while the other one is the +sqlite db. + +One can have multiple config directories with different configurations +each. + +Using the special keyword *config* (or *conf* or *c* or *-c*) you can set the path +in which ck will search for the *.ck* directory. + +You can prefix every action with this and ck will use the configuration +directory of your choice. + +Usage: +#+BEGIN_SRC sh + $ ck config ~/ ... # the default behaviour + + # /someplace/else must exist or + # the action following it must be init + $ ck conf /someplace/else ... + + # same thing + $ ck c /someplace/else ... + $ ck -c /someplace/else ... +#+END_SRC + +** Actions +*** init +or i or -i + +init takes exactly 2 arguments. + +- *config_dir*: where all the configs will live +- *secret_dir*: where all the secret configs will live + +Use init to initialize a new ck database. + +Usage: +#+BEGIN_SRC sh + # initialize new ck + $ ck init /path_to/where_you_want/your_configs/to_be \ + /path_to/the_secret/directory +#+END_SRC + +*** add +or a or -a + +Add takes 2 to 4 arguments. + +- *program_name*: the name of the program you add a config to +- *config_path*: the path to the config +- Optional: (order doesn't matter) + + *-p*: the config will be the primary (relevant on edit below) + + *-s*: the config will be stored in the secret_dir + +Use add to add a new config for ck to keep track of. + +Keep in mind: +- The config has to exist +- If you are adding a config to a program already existing in ckdb make + sure to use the same name +- Each program can have only one primary config + +Usage: +#+BEGIN_SRC sh + # add config to ck + $ ck add program_name config_path [-s] [-p] +#+END_SRC + +*** list +or ls or l or -l + +List can show the *paths* or the *programs* that ck keeps track of. +With the flag *-t* and then one of the follwing types one can change +the way the list is printed: +- *plain*: simple listing (default) +- *python*: print like a python list +- *lisp*: print like a lisp list + +Using the keyword *tree* ck can list the configurations under their +corresponding program. + +#+BEGIN_SRC C + /* TODO: show primary and secret atributes */ +#+END_SRC +Usage: +#+BEGIN_SRC sh + # list tree structure + $ ck list tree + # list paths in python + $ ck l paths -t python + # list programs in lisp + $ ck ls programs -t lisp +#+END_SRC + +*** search +or s or -s + +Perform infile grep in all the configurations ck keeps track of. + +Takes one argument, the *search-term*. + +To search for terms with spaces you have to put them in escaped quotes. +To search for special symbols you have to enclose them in quotes and escape them. + +Usage: +#+BEGIN_SRC sh + # search for parenthesis + $ ck search "\(" + # search term with spaces + $ ck search "\"This is a space\"" + # both + $ ck search "\"(add 2 4)\"" + # and a normal one + $ ck search alias +#+END_SRC + +*** edit +or e or -e +~~--WIP--~~ +Currently edit can only edit the primary config of a program. + +To do it use: +#+BEGIN_SRC sh +$ ck edit program_name +#+END_SRC |