diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | README.html | 1198 | ||||
-rw-r--r-- | ck.1 | 29 | ||||
-rw-r--r-- | src/actionparser.c | 14 | ||||
-rw-r--r-- | src/confparser.c | 42 | ||||
-rw-r--r-- | src/confparser.h | 1 |
6 files changed, 925 insertions, 361 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 16b643d..e3ea656 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ project(ck C) # version set(ck_MAJOR_VERSION 0) set(ck_MINOR_VERSION 9) -set(ck_PATCH_VERSION 0) +set(ck_PATCH_VERSION 1) # Feature test macros set(FEATURE_TEST_MACROS "-D_DEFAULT_SOURCE") diff --git a/README.html b/README.html index 655204c..4c8647c 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-10-29 Mon 17:20 --> +<!-- 2018-11-14 Wed 16:42 --> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>‎</title> @@ -232,36 +232,36 @@ for the JavaScript code in this tag. <h2>Table of Contents</h2> <div id="text-table-of-contents"> <ul> -<li><a href="#org00fe9a3">ck</a> +<li><a href="#orgac39c95">ck</a> <ul> -<li><a href="#orgddefd39">Technicalities</a></li> -<li><a href="#org52a8ede">Download</a></li> +<li><a href="#org2f1cd2a">Technicalities</a></li> +<li><a href="#orgb8c0efd">Download</a></li> </ul> </li> <li><a href="#build-instructions">build it</a> <ul> -<li><a href="#orge924f4c">requirements</a></li> -<li><a href="#orga1d810a">make && install</a></li> +<li><a href="#org9b6c6f0">requirements</a></li> +<li><a href="#org01b87bb">make && install</a></li> </ul> </li> -<li><a href="#org421fdfb">for devs</a> +<li><a href="#org982cbd5">for devs</a> <ul> -<li><a href="#org98bcc06">CMake options</a></li> -<li><a href="#org945fa72">compiler</a></li> -<li><a href="#orge94d2b6">tests</a> +<li><a href="#org6b070c4">CMake options</a></li> +<li><a href="#orgcd2bc40">compiler</a></li> +<li><a href="#orgc1ff7c9">tests</a> <ul> -<li><a href="#org6d98a70">run tests</a></li> -<li><a href="#orgdf6a992">test suite</a></li> +<li><a href="#org7c12f69">run tests</a></li> +<li><a href="#org0629f99">test suite</a></li> </ul> </li> </ul> </li> -<li><a href="#org5444b91">ck configuration</a></li> +<li><a href="#orga05b7b3">ck configuration</a></li> <li><a href="#usage">Usage</a> <ul> -<li><a href="#orgd2e5354">Initialize</a></li> -<li><a href="#orgfc9d01c">Add configs</a></li> -<li><a href="#orga6dee7d">Using the ck actions</a></li> +<li><a href="#orgdeb4b8f">Initialize</a></li> +<li><a href="#org9308f2c">Add configs</a></li> +<li><a href="#org8fcf2fd">Using the ck actions</a></li> </ul> </li> <li><a href="#manpage">manpage</a></li> @@ -269,9 +269,9 @@ for the JavaScript code in this tag. </div> </div> <p align="center"><img src="res/logo.png"></p> -<div id="outline-container-org00fe9a3" class="outline-2"> -<h2 id="org00fe9a3">ck</h2> -<div class="outline-text-2" id="text-org00fe9a3"> +<div id="outline-container-orgac39c95" class="outline-2"> +<h2 id="orgac39c95">ck</h2> +<div class="outline-text-2" id="text-orgac39c95"> <p> <b>The Config Keeper</b> </p> @@ -327,9 +327,9 @@ with the rest of us). </p> </div> -<div id="outline-container-orgddefd39" class="outline-3"> -<h3 id="orgddefd39">Technicalities</h3> -<div class="outline-text-3" id="text-orgddefd39"> +<div id="outline-container-org2f1cd2a" class="outline-3"> +<h3 id="org2f1cd2a">Technicalities</h3> +<div class="outline-text-3" id="text-org2f1cd2a"> <p> Upon adding a config to <b>ck</b>, it moves it to the specified folder and adds a symbolic link back where it came from (<code>ln -s</code>). @@ -342,9 +342,9 @@ majority should). </div> </div> -<div id="outline-container-org52a8ede" class="outline-3"> -<h3 id="org52a8ede">Download</h3> -<div class="outline-text-3" id="text-org52a8ede"> +<div id="outline-container-orgb8c0efd" class="outline-3"> +<h3 id="orgb8c0efd">Download</h3> +<div class="outline-text-3" id="text-orgb8c0efd"> <p> Go ahead and download <b>ck</b> and give it a try. It comes with a help sub-command that explains any inquires you might have. @@ -362,13 +362,13 @@ You can also read the manpage <a href="#manpage">down below</a>. </div> </div> -<div id="outline-container-orgde5aa18" class="outline-2"> -<h2 id="build-instructions"><a id="orgde5aa18"></a>build it</h2> +<div id="outline-container-org262e9ab" class="outline-2"> +<h2 id="build-instructions"><a id="org262e9ab"></a>build it</h2> <div class="outline-text-2" id="text-build-instructions"> </div> -<div id="outline-container-orge924f4c" class="outline-3"> -<h3 id="orge924f4c">requirements</h3> -<div class="outline-text-3" id="text-orge924f4c"> +<div id="outline-container-org9b6c6f0" class="outline-3"> +<h3 id="org9b6c6f0">requirements</h3> +<div class="outline-text-3" id="text-org9b6c6f0"> <ul class="org-ul"> <li>cmake</li> <li>sqlite3-dev</li> @@ -377,24 +377,24 @@ You can also read the manpage <a href="#manpage">down below</a>. </div> </div> -<div id="outline-container-orga1d810a" class="outline-3"> -<h3 id="orga1d810a">make && install</h3> -<div class="outline-text-3" id="text-orga1d810a"> +<div id="outline-container-org01b87bb" class="outline-3"> +<h3 id="org01b87bb">make && install</h3> +<div class="outline-text-3" id="text-org01b87bb"> <p> Use <code>-DCMAKE_INSTALL_PREFIX</code> when running cmake to change the install path. </p> <div class="org-src-container"> -<pre class="src src-sh"><span class="org-comment-delimiter"># </span><span class="org-comment">clone the repo</span> +<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span> > cd ~/code; git clone https://gitlab.com/grm-grm/ck -<span class="org-comment-delimiter"># </span><span class="org-comment">make a build directory and enter it</span> -> mkdir ~/ck_build; <span class="org-builtin">cd</span> ~/ck_build; -<span class="org-comment-delimiter"># </span><span class="org-comment">run cmake</span> +<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> > cmake ~/code/ck -<span class="org-comment-delimiter"># </span><span class="org-comment">run make</span> +<span style="color: #656565;"># </span><span style="color: #757575;">run make</span> > make -<span class="org-comment-delimiter"># </span><span class="org-comment">install it</span> +<span style="color: #656565;"># </span><span style="color: #757575;">install it</span> > make install -<span class="org-comment-delimiter"># </span><span class="org-comment">run ck</span> +<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span> > ck </pre> </div> @@ -402,23 +402,23 @@ Use <code>-DCMAKE_INSTALL_PREFIX</code> when running cmake to change the install </div> </div> -<div id="outline-container-org421fdfb" class="outline-2"> -<h2 id="org421fdfb">for devs</h2> -<div class="outline-text-2" id="text-org421fdfb"> +<div id="outline-container-org982cbd5" class="outline-2"> +<h2 id="org982cbd5">for devs</h2> +<div class="outline-text-2" id="text-org982cbd5"> <p> Please be <a href="https://www.gnu.org/philosophy/kind-communication.html">kind</a> to each other. </p> </div> -<div id="outline-container-org98bcc06" class="outline-3"> -<h3 id="org98bcc06">CMake options</h3> -<div class="outline-text-3" id="text-org98bcc06"> +<div id="outline-container-org6b070c4" class="outline-3"> +<h3 id="org6b070c4">CMake options</h3> +<div class="outline-text-3" id="text-org6b070c4"> <p> cmake accepts the following options: </p> <div class="org-src-container"> -<pre class="src src-cmake"><span class="org-function-name">option</span>(CK_DEBUG <span class="org-string">"Build with debug symbols, asan and warnings"</span>) -<span class="org-function-name">option</span>(CK_TESTS <span class="org-string">"Make the tests"</span>) -<span class="org-function-name">option</span>(CK_SHARED <span class="org-string">"Build with shared lib"</span>) +<pre class="src src-cmake"><span style="color: #6aaf50;">option</span>(CK_DEBUG <span style="color: #bdbc61;">"Build with debug symbols, asan and warnings"</span>) +<span style="color: #6aaf50;">option</span>(CK_TESTS <span style="color: #bdbc61;">"Make the tests"</span>) +<span style="color: #6aaf50;">option</span>(CK_SHARED <span style="color: #bdbc61;">"Build with shared lib"</span>) </pre> </div> @@ -432,41 +432,41 @@ To use any one of them append it after the cmake command like so: </div> </div> -<div id="outline-container-org945fa72" class="outline-3"> -<h3 id="org945fa72">compiler</h3> -<div class="outline-text-3" id="text-org945fa72"> +<div id="outline-container-orgcd2bc40" class="outline-3"> +<h3 id="orgcd2bc40">compiler</h3> +<div class="outline-text-3" id="text-orgcd2bc40"> <p> Pick your favorite </p> <div class="org-src-container"> -<pre class="src src-sh">> export <span class="org-variable-name">CC</span>=clang -<span class="org-comment-delimiter"># </span><span class="org-comment">or</span> -> export <span class="org-variable-name">CC</span>=gcc +<pre class="src src-sh">> export <span style="color: #baba36;">CC</span>=clang +<span style="color: #656565;"># </span><span style="color: #757575;">or</span> +> export <span style="color: #baba36;">CC</span>=gcc </pre> </div> <div class="org-src-container"> -<pre class="src src-sh"><span class="org-comment-delimiter"># </span><span class="org-comment">clone the repo</span> +<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span> > cd ~/code; git clone https://gitlab.com/grm-grm/ck -<span class="org-comment-delimiter"># </span><span class="org-comment">make a build directory and enter it</span> -> mkdir ~/ck_build; <span class="org-builtin">cd</span> ~/ck_build; -<span class="org-comment-delimiter"># </span><span class="org-comment">run cmake</span> +<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> > cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck -<span class="org-comment-delimiter"># </span><span class="org-comment">run make</span> +<span style="color: #656565;"># </span><span style="color: #757575;">run make</span> > make -<span class="org-comment-delimiter"># </span><span class="org-comment">check ck</span> +<span style="color: #656565;"># </span><span style="color: #757575;">check ck</span> > ./test-ck -<span class="org-comment-delimiter"># </span><span class="org-comment">run ck</span> +<span style="color: #656565;"># </span><span style="color: #757575;">run ck</span> > ./ck </pre> </div> </div> </div> -<div id="outline-container-orge94d2b6" class="outline-3"> -<h3 id="orge94d2b6">tests</h3> -<div class="outline-text-3" id="text-orge94d2b6"> +<div id="outline-container-orgc1ff7c9" class="outline-3"> +<h3 id="orgc1ff7c9">tests</h3> +<div class="outline-text-3" id="text-orgc1ff7c9"> <p> The testing "suite" is a bash script that runs regression and unit tests. Regression tests are under the <code>tests/</code> directory @@ -475,9 +475,9 @@ under <code>unit/</code> directory and test the code. </p> </div> -<div id="outline-container-org6d98a70" class="outline-4"> -<h4 id="org6d98a70">run tests</h4> -<div class="outline-text-4" id="text-org6d98a70"> +<div id="outline-container-org7c12f69" class="outline-4"> +<h4 id="org7c12f69">run tests</h4> +<div class="outline-text-4" id="text-org7c12f69"> <p> First make sure you build ck with the <code>-DCK_TESTS=1</code> option. Then go to the build directory and type: @@ -489,9 +489,9 @@ go to the build directory and type: </div> </div> -<div id="outline-container-orgdf6a992" class="outline-4"> -<h4 id="orgdf6a992">test suite</h4> -<div class="outline-text-4" id="text-orgdf6a992"> +<div id="outline-container-org0629f99" class="outline-4"> +<h4 id="org0629f99">test suite</h4> +<div class="outline-text-4" id="text-org0629f99"> <div class="org-src-container"> <pre class="src src-sh">$ ./test-ck -h ck test suite @@ -509,17 +509,17 @@ flags: </div> </div> </div> -<div id="outline-container-org5444b91" class="outline-2"> -<h2 id="org5444b91">ck configuration</h2> -<div class="outline-text-2" id="text-org5444b91"> +<div id="outline-container-orga05b7b3" class="outline-2"> +<h2 id="orga05b7b3">ck configuration</h2> +<div class="outline-text-2" id="text-orga05b7b3"> <p> See the <a href="#manpage">manpage</a> below. </p> </div> </div> -<div id="outline-container-org5727b06" class="outline-2"> -<h2 id="usage"><a id="org5727b06"></a>Usage</h2> +<div id="outline-container-org001e3df" class="outline-2"> +<h2 id="usage"><a id="org001e3df"></a>Usage</h2> <div class="outline-text-2" id="text-usage"> <p> ck's goal is to assist with the configuration file management. @@ -529,91 +529,91 @@ ck's goal is to assist with the configuration file management. This section is an example usage. </p> </div> -<div id="outline-container-orgd2e5354" class="outline-3"> -<h3 id="orgd2e5354">Initialize</h3> -<div class="outline-text-3" id="text-orgd2e5354"> +<div id="outline-container-orgdeb4b8f" class="outline-3"> +<h3 id="orgdeb4b8f">Initialize</h3> +<div class="outline-text-3" id="text-orgdeb4b8f"> <div class="org-src-container"> -<pre class="src src-sh"><span class="org-builtin">cd</span> ~ -<span class="org-comment-delimiter"># </span><span class="org-comment">make the directories for the configs</span> +<pre class="src src-sh"><span style="color: #528fd1;">cd</span> ~ +<span style="color: #656565;"># </span><span style="color: #757575;">make the directories for the configs</span> $ mkdir -p configs/vc configs/sec -<span class="org-comment-delimiter"># </span><span class="org-comment">initialize new ck</span> +<span style="color: #656565;"># </span><span style="color: #757575;">initialize new ck</span> $ ck init configs/vc configs/sec </pre> </div> </div> </div> -<div id="outline-container-orgfc9d01c" class="outline-3"> -<h3 id="orgfc9d01c">Add configs</h3> -<div class="outline-text-3" id="text-orgfc9d01c"> +<div id="outline-container-org9308f2c" class="outline-3"> +<h3 id="org9308f2c">Add configs</h3> +<div class="outline-text-3" id="text-org9308f2c"> <div class="org-src-container"> -<pre class="src src-sh"><span class="org-comment-delimiter"># </span><span class="org-comment">add emacs configs</span> -<span class="org-comment-delimiter">## </span><span class="org-comment">primary config</span> +<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">add emacs configs</span> +<span style="color: #656565;">## </span><span style="color: #757575;">primary config</span> $ ck add emacs .emacs.d/orgconf.org -p -<span class="org-comment-delimiter">## </span><span class="org-comment">secret config, with passwords and naughty words</span> +<span style="color: #656565;">## </span><span style="color: #757575;">secret config, with passwords and naughty words</span> $ ck add emacs .emacs.d/accounts.org -s -<span class="org-comment-delimiter">## </span><span class="org-comment">and another one for emacs</span> +<span style="color: #656565;">## </span><span style="color: #757575;">and another one for emacs</span> $ ck add emacs .emacs.d/init.el -<span class="org-comment-delimiter"># </span><span class="org-comment">add tmux config</span> +<span style="color: #656565;"># </span><span style="color: #757575;">add tmux config</span> $ ck add tmux .tmux.conf -p -<span class="org-comment-delimiter"># </span><span class="org-comment">add X configs</span> +<span style="color: #656565;"># </span><span style="color: #757575;">add X configs</span> $ ck add X .xinitrc $ ck add X .Xresources -<span class="org-comment-delimiter"># </span><span class="org-comment">add ssh configs (secret)</span> +<span style="color: #656565;"># </span><span style="color: #757575;">add ssh configs (secret)</span> $ ck add ssh .ssh/config -s -p $ ck add ssh .ssh/authorized_keys -s -<span class="org-comment-delimiter"># </span><span class="org-comment">When running with sudo, we need to specify the ck config</span> -<span class="org-comment-delimiter"># </span><span class="org-comment">location.</span> +<span style="color: #656565;"># </span><span style="color: #757575;">When running with sudo, we need to specify the ck config</span> +<span style="color: #656565;"># </span><span style="color: #757575;">location.</span> $ sudo ck -c /home/ckuser add ssh /etc/ssh/sshd_config -s </pre> </div> </div> </div> -<div id="outline-container-orga6dee7d" class="outline-3"> -<h3 id="orga6dee7d">Using the ck actions</h3> -<div class="outline-text-3" id="text-orga6dee7d"> +<div id="outline-container-org8fcf2fd" class="outline-3"> +<h3 id="org8fcf2fd">Using the ck actions</h3> +<div class="outline-text-3" id="text-org8fcf2fd"> <div class="org-src-container"> -<pre class="src src-sh"><span class="org-comment-delimiter"># </span><span class="org-comment">list the configs in a treelike structure with basename only</span> +<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">list the configs in a treelike structure with basename only</span> $ ck list tree -b -<span class="org-comment-delimiter"># </span><span class="org-comment">or with the full path & attributes</span> +<span style="color: #656565;"># </span><span style="color: #757575;">or with the full path & attributes</span> $ ck list tree -a -<span class="org-comment-delimiter"># </span><span class="org-comment">list only the paths in python or lisp like lists</span> +<span style="color: #656565;"># </span><span style="color: #757575;">list only the paths in python or lisp like lists</span> $ ck list paths -t lisp $ ck list programs -t python -b -a -<span class="org-comment-delimiter"># </span><span class="org-comment">list emacs configs</span> +<span style="color: #656565;"># </span><span style="color: #757575;">list emacs configs</span> $ ck list -p emacs -<span class="org-comment-delimiter"># </span><span class="org-comment">search the configs</span> +<span style="color: #656565;"># </span><span style="color: #757575;">search the configs</span> $ ck search Hostname -$ ck search <span class="org-string">"search term with spaces"</span> -<span class="org-comment-delimiter"># </span><span class="org-comment">escape symbols</span> -$ ck search <span class="org-string">\(</span> +$ ck search <span style="color: #bdbc61;">"search term with spaces"</span> +<span style="color: #656565;"># </span><span style="color: #757575;">escape symbols</span> +$ ck search <span style="color: #bdbc61;">\(</span> -<span class="org-comment-delimiter"># </span><span class="org-comment">edit the primary config of emacs</span> +<span style="color: #656565;"># </span><span style="color: #757575;">edit the primary config of emacs</span> $ ck edit emacs -<span class="org-comment-delimiter"># </span><span class="org-comment">edit a non-primary config of ssh</span> +<span style="color: #656565;"># </span><span style="color: #757575;">edit a non-primary config of ssh</span> $ ck e ssh authorized_keys -<span class="org-comment-delimiter"># </span><span class="org-comment">edit a root config</span> +<span style="color: #656565;"># </span><span style="color: #757575;">edit a root config</span> $ sudo ck -c /home/ckuser e ssh sshd_config -<span class="org-comment-delimiter"># </span><span class="org-comment">delete a program with all the configs</span> +<span style="color: #656565;"># </span><span style="color: #757575;">delete a program with all the configs</span> $ ck delete emacs -<span class="org-comment-delimiter"># </span><span class="org-comment">or a specific config</span> +<span style="color: #656565;"># </span><span style="color: #757575;">or a specific config</span> $ ck del -c /home/ckuser/.emacs.d/init.el -<span class="org-comment-delimiter"># </span><span class="org-comment">restore all links (on a new instalation)</span> +<span style="color: #656565;"># </span><span style="color: #757575;">restore all links (on a new instalation)</span> $ ck restore all -<span class="org-comment-delimiter"># </span><span class="org-comment">restore a program's links</span> +<span style="color: #656565;"># </span><span style="color: #757575;">restore a program's links</span> $ ck r -p emacs -<span class="org-comment-delimiter"># </span><span class="org-comment">get help for an action</span> +<span style="color: #656565;"># </span><span style="color: #757575;">get help for an action</span> $ ck h add $ ck --help e </pre> @@ -622,11 +622,11 @@ $ ck --help e </div> </div> -<div id="outline-container-org9df6fcc" class="outline-2"> -<h2 id="manpage"><a id="org9df6fcc"></a>manpage</h2> +<div id="outline-container-orgbb97793" class="outline-2"> +<h2 id="manpage"><a id="orgbb97793"></a>manpage</h2> <div class="outline-text-2" id="text-manpage"> <!-- Creator : groff version 1.22.3 --> -<!-- CreationDate: Mon Oct 29 17:20:18 2018 --> +<!-- CreationDate: Wed Nov 14 16:42:24 2018 --> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> @@ -675,29 +675,216 @@ manage configuration across the system</p> </h2> -<p style="margin-left:11%; margin-top: 1em"><b>ck</b> -[<b>−v</b>|<b>−−verbose</b>] -[<b>−c</b>|<b>−−config</b> <i>DIR</i>] -<i>action </i>[...] <b><br> -ck</b> [<b>version</b>|<b>−−version</b>] <b><br> -ck init</b> <i>VERSION_CONTROL_DIR SECRET_DIR</i> <b><br> -ck add</b> <i>PROGRAM_NAME CONFIG_PATH</i> [<b>−p</b>] -[<b>−s</b>] <b><br> -ck delete</b> -<i>PROGRAM_NAME</i>|{<b>−c </b><i>CONFIG_PATH</i>} -<b><br> -ck list tree </b>[<b>−a</b>] [<b>−b</b>] -<b><br> -ck list</b> -{<b>-p </b><i>PROGRAM_NAME</i>}|<b>programs</b>|<b>paths </b>[<b>−t</b> -{<b>plain</b>|<b>python</b>|<b>lisp</b>}] [<b>−a</b>] -[<b>−b</b>] <b><br> -ck list ckconf <br> -ck edit</b> -<i>PROGRAM_NAME </i>[<i>CONFIG_BASENAME</i>] <b><br> -ck search</b> <i>SEARCH_TERM</i> <b><br> -ck restore</b> <i>PROGRAM_NAME</i>|<b>all <br> -ck help</b> <i>action</i></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p style="margin-top: 1em"><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + + +<p style="margin-top: 1em">[<b>−v</b>|<b>−−verbose</b>] +[<b>−c</b>|<b>−−config </b><i>DIR</i>] +<i>action </i>[...]</p> </td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p>[<b>version</b>|<b>−−version</b>]</p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>init</b> <i>VERSION_CONTROL_DIR SECRET_DIR</i></p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>add</b> <i>PROGRAM_NAME CONFIG_PATH</i> +[<b>−p</b>] [<b>−s</b>]</p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>delete</b> <i>PROGRAM_NAME</i> +[<i>CONFIG_BASENAME</i>]</p> </td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list tree</b> [<b>−a</b>] [<b>−b</b>]</p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list −p </b><i>PROGRAM_NAME</i> +[<b>−t </b><i>list-type</i>] [<b>−a</b>] +[<b>−b</b>]</p> </td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list programs</b> +[<b>−t </b><i>list-type</i>] [<b>−a</b>] +[<b>−b</b>]</p> </td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list paths</b> +[<b>−t </b><i>list-type</i>] [<b>−a</b>] +[<b>−b</b>]</p> </td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list ckconf</b></p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>edit</b> <i>PROGRAM_NAME</i> +[<i>CONFIG_BASENAME</i>]</p> </td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>search</b> <i>SEARCH_TERM</i></p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>restore −p</b> <i>PROGRAM_NAME</i></p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>restore all</b></p></td> +<td width="15%"> +</td></tr> +<tr valign="top" align="left"> +<td width="11%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>help </b><i>action</i></p></td> +<td width="15%"> +</td></tr> +</table> <h2>DESCRIPTION <a name="DESCRIPTION"></a> @@ -741,17 +928,25 @@ database.</p> <p style="margin-left:11%; margin-top: 1em"><b>ck</b> uses <b>sqlite</b> to index the configuration files. The <b>init -action</b> by default creates a directory named <i>.ck</i> -under <i>$HOME</i> in witch the <i>ckrc</i> and <i>ckdb</i> -files reside. See the <b>FILES</b> section for more -details.</p> +action</b> by default creates a directory in witch the +<i>ckrc</i> and <i>ckdb</i> files reside. See the +<b>FILES</b> section for more details.</p> + +<p style="margin-left:11%; margin-top: 1em"><b>ck</b> will +first search for the configuration in the folder shown by +the <i>$CK_CONFIG</i> environment variable. If it is set it +will use the <i>ckrc</i> and <i>ckdb</i> inside this +directory. Else it wil use <i>$XDG_CONFIG_HOME/ck</i> and if +that is not set as well it will fall back to +<i>$HOME/.ck</i>.</p> <p style="margin-left:11%; margin-top: 1em">One can have multiple <b>config directories</b> with different configurations each. Using the <b>config </b>or <b>−c</b> option one can set the path in which ck will search for <i>ckrc</i> and -<i>ckdb</i>. See the <b>OPTIONS</b> section for more +<i>ckdb</i>. Using this will ignore any environment +variables. See the <b>OPTIONS</b> section for more details.</p> <h2>OPTIONS @@ -772,8 +967,8 @@ order to work.</p> <i>DIR</i>, <b>−c</b> <i>DIR</i></p> <p style="margin-left:22%;">Use -<b>ckdb </b>and <b>ckrc</b> residing in <i>DIR</i> -instead of the default <i>~/.ck/</i>.</p> +<b>ckdb </b>and <b>ckrc</b> residing in +<i>DIR</i>.</p> <p style="margin-left:11%;"><b>−−version</b>, <b>version</b></p> @@ -795,320 +990,580 @@ section above.</p> <p style="margin-left:11%; margin-top: 1em">Each <b>action</b> takes a number of arguments and flags.</p> -<p style="margin-left:11%; margin-top: 1em"><b>Initialize -ck</b> <br> + +<p style="margin-left:11%; margin-top: 1em"><b>INITIALIZE</b> +<br> Create the <b>ck</b> database (<i>ckdb</i>) and initialize it. Create the ck config file (<i>ckrc</i>) and add the -directory paths to it.</p> +directory paths to it. <b><br> +USAGE</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="54%"> -<p style="margin-left:14%;"><b>ck init</b> -<i>VERSION_CONTROL_DIR SECRET_DIR</i></p> +<p><b>init</b> <i>VERSION_CONTROL_DIR SECRET_DIR</i></p></td> +<td width="28%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>init</b>, <b>i</b>, <b>−i</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="29%"> -<p style="margin-left:14%;"><i>VERSION_CONTROL_DIR</i></p> -<p style="margin-left:17%;">The directory where -<b>configs</b> will be stored by default. <b>File must -exist</b>.</p> +<p><i>VERSION_CONTROL_DIR</i></p></td> +<td width="3%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><i>SECRET_DIR</i></p> +<p>The directory where <b>configs</b> will be stored by +default. <b>File must exist</b>.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="29%"> -<p style="margin-left:17%;">The directory where -<b>configs</b> will be stored when using the <b>−s</b> -flag in <b>add</b>. <b>File must exist</b>.</p> +<p><i>SECRET_DIR</i></p></td> +<td width="3%"></td> +<td width="54%"> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> -<p style="margin-left:14%;">$ ck init -/home/ckuser/configs/vc home/ckuser/configs/sec <br> -$ ck i configs/vc configs/sec</p> +<p>The directory where <b>configs</b> will be stored when +using the <b>−s</b> flag in <b>add</b>. <b>File must +exist</b>.</p> </td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>Add -config</b> <br> +<p style="margin-left:11%;"><b>EXAMPLES</b></p> + +<pre style="margin-left:14%;">$ ck init /home/ckuser/configs/vc home/ckuser/configs/sec +$ ck i configs/vc configs/sec</pre> + + +<p style="margin-left:11%; margin-top: 1em"><b>ADD +CONFIG</b> <br> Add a <b>config</b> to the database (<i>ckdb</i>). Each <b>config</b> belongs to a <b>program</b>. Every <b>program</b> can have multiple <b>configs</b> under it and one of them can be <b>primary</b>. The <b>edit action</b> -will open the <b>primary config</b> by default.</p> +will open the <b>primary config</b> by default. <b><br> +USAGE</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> -<p style="margin-left:14%;"><b>ck add</b> <i>PROGRAM_NAME -CONFIG_PATH</i> [<b>−p</b>] [<b>−s</b>]</p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="59%"> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p><b>add</b> <i>PROGRAM_NAME CONFIG_PATH</i> +[<b>−p</b>] [<b>−s</b>]</p></td> +<td width="23%"> +</td></tr> +</table> + +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>add</b>, <b>a</b>, <b>−a</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="18%"> + + +<p><i>PROGRAM_NAME</i></p></td> +<td width="14%"></td> +<td width="54%"> + + +<p>The name of the <b>program</b> the <b>config</b> belongs +at.</p> </td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="18%"> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> -<p style="margin-left:14%;"><i>PROGRAM_NAME</i></p> +<p><i>CONFIG_PATH</i></p></td> +<td width="14%"></td> +<td width="54%"> -<p style="margin-left:17%;">The name of the <b>program</b> -the <b>config</b> belongs at.</p> +<p>Path to the <b>config</b>. Can be relative.</p></td></tr> +</table> -<p style="margin-left:14%; margin-top: 1em"><i>CONFIG_PATH</i></p> +<p style="margin-left:11%;"><b>FLAGS</b></p> -<p style="margin-left:17%;">Path to the <b>config</b>. Can -be relative.</p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>FLAGS</b></p> +<p><b>−s</b></p></td> +<td width="29%"></td> +<td width="54%"> -<p style="margin-left:14%;"><b>−s</b></p> -<p style="margin-left:17%;">Mark the <b>config</b> as -secret. It will be stored on the <i>SECRET_DIR</i>.</p> +<p>Mark the <b>config</b> as secret. It will be stored on +the <i>SECRET_DIR</i>.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:14%; margin-top: 1em"><b>−p</b></p> +<p><b>−p</b></p></td> +<td width="29%"></td> +<td width="54%"> -<p style="margin-left:17%;">Mark the <b>config</b> as -primary. The <b>edit action</b> will open this by -default.</p> +<p>Mark the <b>config</b> as primary. The <b>edit +action</b> will open this by default.</p></td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> +<p style="margin-left:11%;"><b>EXAMPLES</b></p> -<p style="margin-left:14%;"># add emacs configs <br> -## primary config <br> -$ ck add emacs ~/.emacs.d/orgconf.org -p <br> -## secret config, with passwords <br> -$ ck add emacs ~/.emacs.d/accounts.org -s <br> -## another one for emacs <br> -$ ck add emacs ~/.emacs.d/init.el</p> +<pre style="margin-left:14%;"># add emacs configs +## primary config +$ ck add emacs ~/.emacs.d/orgconf.org -p +## secret config, with passwords +$ ck add emacs ~/.emacs.d/accounts.org -s +## another one for emacs +$ ck add emacs ~/.emacs.d/init.el</pre> -<p style="margin-left:11%; margin-top: 1em"><b>Delete -config</b> <br> + +<p style="margin-left:11%; margin-top: 1em"><b>DELETE +CONFIG</b> <br> Delete a <b>config</b> or a <b>program</b> from the database (<i>ckdb</i>). This will not touch the actual file and link. -It is up to the user to handle it.</p> +It is up to the user to handle it. <b><br> +USAGE</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="57%"> -<p style="margin-left:14%;"><b>ck delete</b> -<i>PROGRAM_NAME</i>|{<b>−c </b><i>CONFIG_PATH</i>}</p> +<p><b>delete</b> <i>PROGRAM_NAME</i> +[<i>CONFIG_BASENAME</i>]</p> </td> +<td width="25%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>delete</b>, <b>del</b>, <b>d</b>, <b>−d</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:14%;"><i>PROGRAM_NAME</i></p> -<p style="margin-left:17%;">Delete the <b>program</b> and -all it’s <b>configs</b>.</p> +<p><i>PROGRAM_NAME</i></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><b>−c </b><i>CONFIG_PATH</i></p> +<p>Delete the <b>program</b> and all it’s +<b>configs</b>.</p> </td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:17%;">Delete the <b>config</b>. This -has to be the full path of the link as shown by the <b>list -action</b>.</p> +<p><i>CONFIG_BASENAME</i></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b> -<br> -$ ck delete emacs <br> -$ ck del -c /home/ckuser/.emacs.d/init.el</p> -<p style="margin-left:11%; margin-top: 1em"><b>List</b> -<br> -List programs, configs and ck configuration values.</p> +<p>The basename of the <b>config</b> file to be deleted. It +has to follow the <i>PROGRAM_NAME</i>.</p></td></tr> +</table> + +<p style="margin-left:11%;"><b>EXAMPLES</b></p> + +<pre style="margin-left:14%;">$ ck delete emacs +$ ck del emacs init.el</pre> + + +<p style="margin-left:11%; margin-top: 1em"><b>LIST +VALUES</b> <br> +List programs, configs and ck configuration values. <b><br> +USAGE</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list tree</b> [<b>−a</b>] [<b>−b</b>]</p></td> +<td width="12%"> +</td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list −p </b><i>PROGRAM_NAME</i> +[<b>−t </b><i>list-type</i>] [<b>−a</b>] +[<b>−b</b>]</p> </td> +<td width="12%"> +</td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list programs</b> +[<b>−t </b><i>list-type</i>] [<b>−a</b>] +[<b>−b</b>]</p> </td> +<td width="12%"> +</td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> + + +<p><b>list paths</b> +[<b>−t </b><i>list-type</i>] [<b>−a</b>] +[<b>−b</b>]</p> </td> +<td width="12%"> +</td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="70%"> -<p style="margin-left:14%;"><b>ck list -tree </b>[<b>−a</b>] [<b>−b</b>] <b><br> -ck list</b> -{<b>-p </b><i>PROGRAM_NAME</i>}|<b>programs</b>|<b>paths </b>[<b>−t</b> -{<b>plain</b>|<b>python</b>|<b>lisp</b>}] [<b>−a</b>] -[<b>−b</b>] <b><br> -ck list ckconf</b></p> +<p><b>list ckconf</b></p></td> +<td width="12%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>list</b>, <b>ls</b>, <b>l</b>, <b>-ls</b>, <b>−l</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:14%;"><b>tree</b></p> -<p style="margin-left:17%;">List <b>programs</b> with their -<b>configs</b> in a tree like structure.</p> +<p><b>tree</b></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><b>paths</b></p> +<p>List <b>programs</b> with their <b>configs</b> in a tree +like structure.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:17%;">List all the <b>config</b> -paths <b>ck</b> keeps track of.</p> +<p><b>paths</b></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><b>programs</b></p> -<p style="margin-left:17%;">List all the <b>programs ck</b> -keeps track of.</p> +<p>List all the <b>config</b> paths <b>ck</b> keeps track +of.</p> </td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:14%; margin-top: 1em"><b>−c </b><i>PROGRAM_NAME</i></p> +<p><b>programs</b></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:17%;">List all the <b>configs</b> of -<i>PROGRAM_NAME</i>.</p> +<p>List all the <b>programs ck</b> keeps track of.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:14%; margin-top: 1em"><b>ckconf</b></p> -<p style="margin-left:17%;">List the <b>ck</b> -configuration values, like the -<i>VERSION_CONTROL_DIR </i>and <i>SECRET_DIR</i>.</p> +<p><b>−c </b><i>PROGRAM_NAME</i></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:11%; margin-top: 1em"><b>FLAGS</b></p> +<p>List all the <b>configs</b> of <i>PROGRAM_NAME</i>.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:14%;"><b>−t</b></p> -<p style="margin-left:17%;">Set the type of the -<b>list</b>. Can be either <b>plain</b> (the default) a -simple list, <b>python</b> to print it like a python array -or <b>lisp</b> to print it like a lisp list.</p> +<p><b>ckconf</b></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><b>−a</b></p> +<p>List the <b>ck</b> configuration values, like the +<i>VERSION_CONTROL_DIR </i>and <i>SECRET_DIR</i>.</p> </td></tr> +</table> -<p style="margin-left:17%;">Add attributes to the listing -(when aplicable). The attributes are <b>[s]</b> for -<b>secret</b>, <b>[p]</b> for <b>primary</b> and -<b>[root]</b> if the file is owned by the root user.</p> +<p style="margin-left:11%;"><b>FLAGS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="11%"> -<p style="margin-left:14%; margin-top: 1em"><b>−b</b></p> -<p style="margin-left:17%;">Print the <b>config</b> -basename instead of the full path.</p> +<p><b>−t </b><i>type</i></p></td> +<td width="21%"></td> +<td width="54%"> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> +<p>Set the type of the <b>list</b>. Can be either +<b>plain</b> (the default) a simple list, <b>python</b> to +print it like a python array or <b>lisp</b> to print it like +a lisp list.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="11%"> -<p style="margin-left:14%;">$ ck list tree -a <br> -$ ck list paths -t lisp <br> -$ ck list programs -t python <br> -$ ck list -p emacs</p> -<p style="margin-left:11%; margin-top: 1em"><b>Edit -configs</b> <br> +<p><b>−a</b></p></td> +<td width="21%"></td> +<td width="54%"> + + +<p>Show attributes to the listing (when aplicable). These +are <b>[s]</b> for <b>secret</b>, <b>[p]</b> for +<b>primary</b> and <b>[root]</b> if the file is owned by the +root user.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="11%"> + + +<p><b>−b</b></p></td> +<td width="21%"></td> +<td width="54%"> + + +<p>Print the <b>config</b> basename instead of the full +path.</p> </td></tr> +</table> + +<p style="margin-left:11%;"><b>EXAMPLES</b></p> + +<pre style="margin-left:14%;">$ ck list tree -a +$ ck list paths -t lisp +$ ck list programs -t python +$ ck list -p emacs</pre> + + +<p style="margin-left:11%; margin-top: 1em"><b>EDIT +CONFIGS</b> <br> Edit a <b>config</b> stored in <b>ck</b> with the <i>$EDITOR</i>. <b>Edit</b> will open the <b>primary config</b> of the <b>program</b>. If there is no <b>primary config</b> but the <b>program</b> only has one <b>config</b>, <b>edit</b> will open that. Whenever there is -ambiguity, a list of possible <b>configs</b> will be -shown.</p> +ambiguity, a list of possible <b>configs</b> will be shown. +<b><br> +USAGE</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="54%"> -<p style="margin-left:14%;"><b>ck edit</b> -<i>PROGRAM_NAME </i>[<i>CONFIG_BASENAME</i>]</p> +<p><b>edit</b> <i>PROGRAM_NAME</i> +[<i>CONFIG_BASENAME</i>]</p> </td> +<td width="28%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>edit</b>, <b>e</b>, <b>−e</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:14%;"><i>PROGRAM_NAME</i></p> -<p style="margin-left:17%;">The name of the <b>program</b> -to be edited. If the <b>program</b> has only one -<b>config</b> or you want to edit the <b>primary</b> one, no -further action is required.</p> +<p><i>PROGRAM_NAME</i></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><i>CONFIG_BASENAME</i></p> +<p>The name of the <b>program</b> to be edited. If the +<b>program</b> has only one <b>config</b> or you want to +edit the <b>primary</b> one, no further action is +required.</p> </td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="23%"> -<p style="margin-left:17%;">The basename of the -<b>config</b> to be edited. This has to follow the -<b>program</b> name. It is only needed when editing a -<b>config</b> other than the <b>primary</b> one.</p> +<p><i>CONFIG_BASENAME</i></p></td> +<td width="9%"></td> +<td width="54%"> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> -<p style="margin-left:14%;">$ ck edit emacs <br> -$ ck e tmux .tmux.conf</p> +<p>The basename of the <b>config</b> to be edited. This has +to follow the <i>PROGRAM_NAME</i> name. It is only needed +when editing a <b>config</b> other than the <b>primary</b> +one.</p> </td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>Search -configs</b> <br> +<p style="margin-left:11%;"><b>EXAMPLES</b></p> + +<pre style="margin-left:14%;">$ ck edit emacs +$ ck e tmux .tmux.conf</pre> + + +<p style="margin-left:11%; margin-top: 1em"><b>SEARCH +CONFIGS</b> <br> Grep through the configs. This <b>action</b> is equivalent to this:</p> -<p style="margin-left:11%; margin-top: 1em">$ ck ls paths | -xargs grep -H -n "search term"</p> +<p style="margin-left:14%;">$ ck ls paths | xargs grep -H +-n "search term"</p> + +<p style="margin-left:11%;">Thus for more advanced search +through the <b>configs</b> one can use other programs and +replace grep in the command above. <b><br> +USAGE</b></p> -<p style="margin-left:11%; margin-top: 1em">Thus for more -advanced search through the <b>configs</b> one can use other -programs and replace grep in the command above.</p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="28%"> -<p style="margin-left:14%;"><b>ck search</b> -<i>SEARCH_TERM</i></p> +<p><b>search</b> <i>SEARCH_TERM</i></p></td> +<td width="54%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>search</b>, <b>grep</b>, <b>s</b>, <b>−s</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="17%"> -<p style="margin-left:14%;"><i>SEARCH_TERM</i></p> -<p style="margin-left:17%;">The term you wish to search -for. If it’s a phrase enclose it in "". If -it’s a special character you can escape it with \ -(backslash).</p> +<p><i>SEARCH_TERM</i></p></td> +<td width="15%"></td> +<td width="54%"> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> +<p>The term you wish to search for. If it’s a phrase +enclose it in "". If it’s a special +character you can escape it with \ (backslash).</p></td></tr> +</table> -<p style="margin-left:14%;">$ ck search "search -term" $ ck search "quire"</p> +<p style="margin-left:11%;"><b>EXAMPLES</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>Restore -configs</b> <br> +<pre style="margin-left:14%;">$ ck search "search term" +$ ck search "\(require"</pre> + + +<p style="margin-left:11%; margin-top: 1em"><b>RESTORE +CONFIGS</b> <br> Given a working <b>ck</b> instance (<i>ckdb</i> + <i>ckrc</i> + directories in <i>ckrc</i> with <b>configs</b>), <b>restore</b> shall recreate the @@ -1143,70 +1598,130 @@ checks that the <b>configs</b> exist and that the location for the link is avaliable before making any links. However, in the even that <b>symlink</b> fails for some other reason, the process will stop as is. The user will have to take care -of the already created links, if that’s the case.</p> +of the already created links, if that’s the case. +<b><br> +USAGE</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> + + +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="36%"> + + +<p><b>restore −p</b> <i>PROGRAM_NAME</i></p></td> +<td width="46%"> +</td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="36%"> -<p style="margin-left:14%;"><b>ck restore</b> -<i>PROGRAM_NAME</i>|<b>all</b></p> +<p><b>restore all</b></p></td> +<td width="46%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>restore</b>, <b>r</b>, <b>−r</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="18%"> -<p style="margin-left:14%;"><i>PROGRAM_NAME</i></p> -<p style="margin-left:17%;">The name of the <b>program</b> -to be restored.</p> +<p><i>PROGRAM_NAME</i></p></td> +<td width="14%"></td> +<td width="54%"> -<p style="margin-left:14%; margin-top: 1em"><b>all</b></p> -<p style="margin-left:17%;">Restore all <b>programs ck</b> -keeps track of.</p> +<p>The name of the <b>program</b> to be restored.</p></td></tr> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="18%"> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> +<p><b>all</b></p></td> +<td width="14%"></td> +<td width="54%"> -<p style="margin-left:14%;">$ ck restore all <br> -$ ck restore -p emacs</p> -<p style="margin-left:11%; margin-top: 1em"><b>Get help</b> +<p>Restore all <b>programs ck</b> keeps track of.</p></td></tr> +</table> + +<p style="margin-left:11%;"><b>EXAMPLES</b></p> + +<pre style="margin-left:14%;">$ ck restore all +$ ck restore -p emacs</pre> + + +<p style="margin-left:11%; margin-top: 1em"><b>GET HELP</b> <br> -Get help for any given <b>action</b> from the command -line.</p> +Get help for any given <b>action</b> from the command line. +<b><br> +USAGE</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="3%"> -<p style="margin-left:11%; margin-top: 1em"><b>USAGE</b></p> +<p><b>ck</b></p></td> +<td width="1%"></td> +<td width="17%"> -<p style="margin-left:14%;"><b>ck help</b> -<i>action</i></p> +<p><b>help </b><i>action</i></p></td> +<td width="65%"> +</td></tr> +</table> -<p style="margin-left:11%; margin-top: 1em"><b>ALIASES</b></p> +<p style="margin-left:11%;"><b>ALIASES</b></p> <p style="margin-left:14%;"><b>help</b>, <b>h</b>, <b>−−help</b>, <b>-h</b>, <b>−?</b></p> +<p style="margin-left:11%;"><b>ARGUMENTS</b></p> + +<table width="100%" border="0" rules="none" frame="void" + cellspacing="0" cellpadding="0"> +<tr valign="top" align="left"> +<td width="14%"></td> +<td width="9%"> + -<p style="margin-left:11%; margin-top: 1em"><b>ARGUMENTS</b></p> +<p><i>action</i></p></td> +<td width="23%"></td> +<td width="54%"> -<p style="margin-left:14%;"><i>action</i></p> -<p style="margin-left:17%;">Any <b>action alias</b> you -wish to get help for.</p> +<p>Any <b>action alias</b> you wish to get help for.</p></td></tr> +</table> +<p style="margin-left:11%;"><b>EXAMPLES</b></p> -<p style="margin-left:11%; margin-top: 1em"><b>EXAMPLES</b></p> +<pre style="margin-left:14%;">$ ck help add +$ ck h d +$ ck --help ls</pre> -<p style="margin-left:14%;">$ ck help add <br> -$ ck h d <br> -$ ck --help ls</p> <h2>EXIT STATUS <a name="EXIT STATUS"></a> @@ -1223,9 +1738,10 @@ otherwise</p> <p style="margin-left:11%; margin-top: 1em">By default -<b>ck</b> will store it’s files in <i>~/.ck/</i>. -Using the <b>−c</b>|<b>−−config</b> one -can change this.</p> +<b>ck</b> will store it’s files in <i>$CK_CONFIG</i> +> <i>$XDG_CONFIG_HOME/ck</i> > <i>$HOME/.ck</i>. Using +the <b>−c</b>|<b>−−config</b> one can +change this.</p> <p style="margin-left:11%; margin-top: 1em"><b>ck generated files</b> <i><br> @@ -1285,7 +1801,7 @@ flags</b>: @CMAKE_C_FLAGS@</p> </div> </div> <div id="postamble" class="status"> -<p class="date">Created: 2018-10-29 Mon 17:20</p> +<p class="date">Created: 2018-11-14 Wed 16:42</p> <p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p> </div> </body> @@ -137,10 +137,7 @@ uses .B sqlite to index the configuration files. The .B init action -by default creates a directory named -.I .ck -under -.I $HOME +by default creates a directory in witch the .I ckrc and @@ -149,6 +146,18 @@ files reside. See the .B FILES section for more details. .P +.B ck +will first search for the configuration in the folder shown by the +.I $CK_CONFIG +environment variable. If it is set it will use the +.I ckrc +and +.I ckdb +inside this directory. Else it wil use +.I $XDG_CONFIG_HOME/ck +and if that is not set as well it will fall back to +.IR $HOME/.ck . +.P One can have multiple .B config directories with different configurations each. @@ -159,7 +168,7 @@ in which ck will search for .I ckrc and .IR ckdb . -See the +Using this will ignore any environment variables. See the .B OPTIONS section for more details. .P @@ -178,9 +187,7 @@ Currently prints the log. Must be the first argument in order to work. Use .BR ckdb \ and \ ckrc residing in -.I DIR -instead of the default -.IR ~/.ck/ . +.IR DIR . .TP .B \-\-version\fR, \fBversion Print version and licence information, and quit. @@ -732,7 +739,11 @@ shall return 0 if the action was completed without an error, -1 otherwise By default .B ck will store it's files in -.IR ~/.ck/ . +.I $CK_CONFIG +> +.I $XDG_CONFIG_HOME/ck +> +.IR $HOME/.ck . Using the .BR \-c | \-\-config one can change this. diff --git a/src/actionparser.c b/src/actionparser.c index 5c6abf7..9ca2867 100644 --- a/src/actionparser.c +++ b/src/actionparser.c @@ -10,6 +10,7 @@ * -------------------------------------------------------------------------- */ #include "ckutil.h" #include "actionparser.h" +#include "confparser.h" #include "ckinfo.h" #include "ckerrlog.h" @@ -236,10 +237,9 @@ void free_user_opt(UserOpt *opt) { list_free(opt->args); } -/* If the used has specified a config file other - * than the default get it now */ +/* find the correct config */ int get_config(UserOpt *opt) { - /* get first token */ + /* If it's a cli option */ if (next_token()) { for (int i = 1; i < atoi(strConfDir[0]) + 1; i++) { if (strcmp(token, strConfDir[i]) == 0) { @@ -262,16 +262,12 @@ int get_config(UserOpt *opt) { return 0; } } - // rewind + /* rewind */ pos = pos - 1; token = opts[pos]; } - char defaultConf[STR_S] = ".ck"; - char * home = getenv("HOME"); - opt->confDir = malloc(strlen(defaultConf) + 1 /* '/' */ + strlen(home) + 1); - str_join_dirname_with_basename(opt->confDir, home, defaultConf); - return 0; + return find_config(opt); } int version() { diff --git a/src/confparser.c b/src/confparser.c index 019cf14..046bee7 100644 --- a/src/confparser.c +++ b/src/confparser.c @@ -14,7 +14,7 @@ ERRLOG(configfile); -const char * const CONFIG_NAME = "/ckrc"; +static const char * const CONFIG_NAME = "/ckrc"; void initialize_conf(Conf *c) { #define X(var, str, name) \ @@ -53,6 +53,46 @@ void make_config_name(char * ret, const char *confPath) { strcpy(ret, tmp); } +int find_config(UserOpt *opt) { + /* If env CK_CONFIG is set */ + char *config_home = getenv("CK_CONFIG"); + if (config_home) { + if (util_is_dir(config_home)) { + opt->confDir = strdup(config_home); + LOG("Using $CK_CONFIG: %s", config_home); + return 0; + } + } + LOG("$CK_CONFIG not avaliable.") + + /* If XDG_CONFIG_HOME exists*/ + config_home = getenv("XDG_CONFIG_HOME"); + if (config_home) { + if (util_is_dir(config_home)) { + char defaultConf[STR_S] = "ck"; + opt->confDir = malloc(strlen(config_home) + 1 /* '/' */ + strlen(defaultConf) + 1); + str_join_dirname_with_basename(opt->confDir, config_home, defaultConf); + LOG("Using $XDG_CONFIG_HOME: %s", config_home); + return 0; + } + } + LOG("$XDG_CONFIG_HOME not avaliable.") + + /* fallback to HOME/.ck */ + config_home = getenv("HOME"); + if (config_home) { + if (util_is_dir(config_home)) { + char defaultConf[STR_S] = ".ck"; + opt->confDir = malloc(strlen(config_home) + 1 /* '/' */ + strlen(defaultConf) + 1); + str_join_dirname_with_basename(opt->confDir, config_home, defaultConf); + LOG("Using $HOME: %s", config_home); + return 0; + } + } + LOG("$XDG_CONFIG_HOME not avaliable."); + return -1; +} + int config_file_parse(Conf *conf, UserOpt *opt) { LOG("Using '%s' for ck configuration directory", opt->confDir); FILE *confPtr; diff --git a/src/confparser.h b/src/confparser.h index d8013e0..11ada7f 100644 --- a/src/confparser.h +++ b/src/confparser.h @@ -43,6 +43,7 @@ struct ConfigValues { int config_file_parse(Conf *conf, UserOpt *opt); void make_config_name(char * ret, const char *confPath); +int find_config(UserOpt *opt); void initialize_conf(Conf *conf); void free_conf(Conf *conf); #endif // CONFPARSER_H |