aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt2
-rw-r--r--README.html154
-rw-r--r--README.org6
-rwxr-xr-xres/test-ck2
-rw-r--r--src/actionhelper.c21
-rw-r--r--src/actionhelper.h3
-rw-r--r--src/actionparser.c2
-rw-r--r--src/actions.c10
-rw-r--r--tests/00_init2
-rw-r--r--tests/01_add2
-rw-r--r--tests/02_list4
-rw-r--r--tests/03_delete14
-rw-r--r--tests/04_search2
13 files changed, 126 insertions, 98 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1709ba4..78a3ab7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,6 +98,8 @@ add_executable(ck ${ckBin_src})
target_link_libraries(ck ckLib)
target_link_libraries(ck ${SQLITE3_LIBRARIES})
+install(TARGETS ck DESTINATION bin)
+
if (CK_TESTS)
## unit test
add_executable(ck-test ${ckUnitTest_src})
diff --git a/README.html b/README.html
index 43d1e52..9bbb656 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-14 Sun 15:34 -->
+<!-- 2018-10-19 Fri 13:06 -->
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>&lrm;</title>
@@ -232,35 +232,35 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
-<li><a href="#orgec60647">ck</a></li>
-<li><a href="#orgbcde368">build it</a>
+<li><a href="#orgfda6b85">ck</a></li>
+<li><a href="#org81f18da">build it</a>
<ul>
-<li><a href="#orgbe60211">requirements</a></li>
-<li><a href="#org6e5c495">compiler</a></li>
-<li><a href="#org8412114">make</a></li>
+<li><a href="#orgca5f041">requirements</a></li>
+<li><a href="#org42b1074">compiler</a></li>
+<li><a href="#org3c16cc6">make</a></li>
</ul>
</li>
-<li><a href="#org45c9b1b">for devs</a>
+<li><a href="#orgb5f4d41">for devs</a>
<ul>
-<li><a href="#org216d8fb">CMake options</a></li>
-<li><a href="#org38a8c1e">tests</a>
+<li><a href="#org359975d">CMake options</a></li>
+<li><a href="#org2d42457">tests</a>
<ul>
-<li><a href="#org9ddf7d4">run tests</a></li>
-<li><a href="#orga13f82c">test suite</a></li>
+<li><a href="#org14b5d19">run tests</a></li>
+<li><a href="#org4539733">test suite</a></li>
</ul>
</li>
</ul>
</li>
-<li><a href="#org20e6b79">manual</a>
+<li><a href="#org9c9d0fe">manual</a>
<ul>
-<li><a href="#orgc277695">ck configuration</a></li>
-<li><a href="#org85d9032">Actions</a>
+<li><a href="#orgbcee4b6">ck configuration</a></li>
+<li><a href="#org67f2600">Actions</a>
<ul>
-<li><a href="#org3eca970">init</a></li>
-<li><a href="#org050bee7">add</a></li>
-<li><a href="#org5953bcd">list</a></li>
-<li><a href="#orgdc17ce6">search</a></li>
-<li><a href="#org854b5f8">edit</a></li>
+<li><a href="#org85fb98c">init</a></li>
+<li><a href="#org139047f">add</a></li>
+<li><a href="#org2c7f2ea">list</a></li>
+<li><a href="#orge8ba31a">search</a></li>
+<li><a href="#org6d1d447">edit</a></li>
</ul>
</li>
</ul>
@@ -269,22 +269,22 @@ for the JavaScript code in this tag.
</div>
</div>
<p align="center"><img src="res/logo.png"></p>
-<div id="outline-container-orgec60647" class="outline-2">
-<h2 id="orgec60647">ck</h2>
-<div class="outline-text-2" id="text-orgec60647">
+<div id="outline-container-orgfda6b85" class="outline-2">
+<h2 id="orgfda6b85">ck</h2>
+<div class="outline-text-2" id="text-orgfda6b85">
<p>
<b>The Config Keeper</b>
</p>
</div>
</div>
-<div id="outline-container-orgbcde368" class="outline-2">
-<h2 id="orgbcde368">build it</h2>
-<div class="outline-text-2" id="text-orgbcde368">
+<div id="outline-container-org81f18da" class="outline-2">
+<h2 id="org81f18da">build it</h2>
+<div class="outline-text-2" id="text-org81f18da">
</div>
-<div id="outline-container-orgbe60211" class="outline-3">
-<h3 id="orgbe60211">requirements</h3>
-<div class="outline-text-3" id="text-orgbe60211">
+<div id="outline-container-orgca5f041" class="outline-3">
+<h3 id="orgca5f041">requirements</h3>
+<div class="outline-text-3" id="text-orgca5f041">
<ul class="org-ul">
<li>clang (llvm) or gcc (gnu)</li>
<li>cmake</li>
@@ -293,9 +293,9 @@ for the JavaScript code in this tag.
</div>
</div>
-<div id="outline-container-org6e5c495" class="outline-3">
-<h3 id="org6e5c495">compiler</h3>
-<div class="outline-text-3" id="text-org6e5c495">
+<div id="outline-container-org42b1074" class="outline-3">
+<h3 id="org42b1074">compiler</h3>
+<div class="outline-text-3" id="text-org42b1074">
<div class="org-src-container">
<pre class="src src-sh">&gt; export <span style="color: #baba36;">CC</span>=clang
<span style="color: #656565;"># </span><span style="color: #757575;">or</span>
@@ -305,9 +305,9 @@ for the JavaScript code in this tag.
</div>
</div>
-<div id="outline-container-org8412114" class="outline-3">
-<h3 id="org8412114">make</h3>
-<div class="outline-text-3" id="text-org8412114">
+<div id="outline-container-org3c16cc6" class="outline-3">
+<h3 id="org3c16cc6">make</h3>
+<div class="outline-text-3" id="text-org3c16cc6">
<div class="org-src-container">
<pre class="src src-sh"><span style="color: #656565;"># </span><span style="color: #757575;">clone the repo</span>
&gt; cd ~/code; git clone https://gitlab.com/grm-grm/ck
@@ -325,13 +325,13 @@ for the JavaScript code in this tag.
</div>
</div>
-<div id="outline-container-org45c9b1b" class="outline-2">
-<h2 id="org45c9b1b">for devs</h2>
-<div class="outline-text-2" id="text-org45c9b1b">
+<div id="outline-container-orgb5f4d41" class="outline-2">
+<h2 id="orgb5f4d41">for devs</h2>
+<div class="outline-text-2" id="text-orgb5f4d41">
</div>
-<div id="outline-container-org216d8fb" class="outline-3">
-<h3 id="org216d8fb">CMake options</h3>
-<div class="outline-text-3" id="text-org216d8fb">
+<div id="outline-container-org359975d" class="outline-3">
+<h3 id="org359975d">CMake options</h3>
+<div class="outline-text-3" id="text-org359975d">
<p>
cmake accepts the following options:
</p>
@@ -371,9 +371,9 @@ llvm has better asan than gcc, so I use that.
</div>
</div>
-<div id="outline-container-org38a8c1e" class="outline-3">
-<h3 id="org38a8c1e">tests</h3>
-<div class="outline-text-3" id="text-org38a8c1e">
+<div id="outline-container-org2d42457" class="outline-3">
+<h3 id="org2d42457">tests</h3>
+<div class="outline-text-3" id="text-org2d42457">
<p>
The testing "suite" is a bash script that runs regression
and unit tests. Regression tests are under the <code>tests/</code> directory
@@ -382,9 +382,9 @@ under <code>unit/</code> directory and test the code.
</p>
</div>
-<div id="outline-container-org9ddf7d4" class="outline-4">
-<h4 id="org9ddf7d4">run tests</h4>
-<div class="outline-text-4" id="text-org9ddf7d4">
+<div id="outline-container-org14b5d19" class="outline-4">
+<h4 id="org14b5d19">run tests</h4>
+<div class="outline-text-4" id="text-org14b5d19">
<p>
First make sure you build ck with the <code>-DCK_TESTS=1</code> option. Then
go to the build directory and type:
@@ -396,9 +396,9 @@ go to the build directory and type:
</div>
</div>
-<div id="outline-container-orga13f82c" class="outline-4">
-<h4 id="orga13f82c">test suite</h4>
-<div class="outline-text-4" id="text-orga13f82c">
+<div id="outline-container-org4539733" class="outline-4">
+<h4 id="org4539733">test suite</h4>
+<div class="outline-text-4" id="text-org4539733">
<div class="org-src-container">
<pre class="src src-sh">$ ./test-ck -h
ck test suite
@@ -416,9 +416,9 @@ flags:
</div>
</div>
</div>
-<div id="outline-container-org20e6b79" class="outline-2">
-<h2 id="org20e6b79">manual</h2>
-<div class="outline-text-2" id="text-org20e6b79">
+<div id="outline-container-org9c9d0fe" class="outline-2">
+<h2 id="org9c9d0fe">manual</h2>
+<div class="outline-text-2" id="text-org9c9d0fe">
<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
@@ -469,9 +469,9 @@ of flags one has to pass to ck.
</p>
</div>
-<div id="outline-container-orgc277695" class="outline-3">
-<h3 id="orgc277695">ck configuration</h3>
-<div class="outline-text-3" id="text-orgc277695">
+<div id="outline-container-orgbcee4b6" class="outline-3">
+<h3 id="orgbcee4b6">ck configuration</h3>
+<div class="outline-text-3" id="text-orgbcee4b6">
<p>
ck uses sqlite to index the configuration files. The init
action creates a <b>.ck</b> directory (under $HOME)
@@ -486,7 +486,7 @@ 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
+Using the special keyword <b>config</b> (or <b>-c</b>) you can set the path
in which ck will search for the <b>.ck</b> directory.
</p>
@@ -503,23 +503,19 @@ Usage:
<span style="color: #656565;"># </span><span style="color: #757575;">/someplace/else must exist or</span>
<span style="color: #656565;"># </span><span style="color: #757575;">the action following it must be init</span>
-$ ck conf /someplace/else ...
-
-<span style="color: #656565;"># </span><span style="color: #757575;">same thing</span>
-$ ck c /someplace/else ...
$ ck -c /someplace/else ...
</pre>
</div>
</div>
</div>
-<div id="outline-container-org85d9032" class="outline-3">
-<h3 id="org85d9032">Actions</h3>
-<div class="outline-text-3" id="text-org85d9032">
+<div id="outline-container-org67f2600" class="outline-3">
+<h3 id="org67f2600">Actions</h3>
+<div class="outline-text-3" id="text-org67f2600">
</div>
-<div id="outline-container-org3eca970" class="outline-4">
-<h4 id="org3eca970">init</h4>
-<div class="outline-text-4" id="text-org3eca970">
+<div id="outline-container-org85fb98c" class="outline-4">
+<h4 id="org85fb98c">init</h4>
+<div class="outline-text-4" id="text-org85fb98c">
<p>
or i or -i
</p>
@@ -549,9 +545,9 @@ $ ck init /path_to/where_you_want/your_configs/to_be <span style="color: #bdbc61
</div>
</div>
-<div id="outline-container-org050bee7" class="outline-4">
-<h4 id="org050bee7">add</h4>
-<div class="outline-text-4" id="text-org050bee7">
+<div id="outline-container-org139047f" class="outline-4">
+<h4 id="org139047f">add</h4>
+<div class="outline-text-4" id="text-org139047f">
<p>
or a or -a
</p>
@@ -592,9 +588,9 @@ $ ck add program_name config_path [-s] [-p]
</div>
</div>
-<div id="outline-container-org5953bcd" class="outline-4">
-<h4 id="org5953bcd">list</h4>
-<div class="outline-text-4" id="text-org5953bcd">
+<div id="outline-container-org2c7f2ea" class="outline-4">
+<h4 id="org2c7f2ea">list</h4>
+<div class="outline-text-4" id="text-org2c7f2ea">
<p>
or ls or l or -l
</p>
@@ -657,9 +653,9 @@ $ ck -l ckconf
</div>
</div>
-<div id="outline-container-orgdc17ce6" class="outline-4">
-<h4 id="orgdc17ce6">search</h4>
-<div class="outline-text-4" id="text-orgdc17ce6">
+<div id="outline-container-orge8ba31a" class="outline-4">
+<h4 id="orge8ba31a">search</h4>
+<div class="outline-text-4" id="text-orge8ba31a">
<p>
or grep or s or -s
</p>
@@ -708,9 +704,9 @@ $ for i ($(ck ls paths)) grep -E <span style="color: #bdbc61;">'A|B'</span> $<sp
</div>
</div>
-<div id="outline-container-org854b5f8" class="outline-4">
-<h4 id="org854b5f8">edit</h4>
-<div class="outline-text-4" id="text-org854b5f8">
+<div id="outline-container-org6d1d447" class="outline-4">
+<h4 id="org6d1d447">edit</h4>
+<div class="outline-text-4" id="text-org6d1d447">
<p>
or e or -e
</p>
@@ -759,7 +755,7 @@ $ ck edit emacs accounts.el
</div>
</div>
<div id="postamble" class="status">
-<p class="date">Created: 2018-10-14 Sun 15:34</p>
+<p class="date">Created: 2018-10-19 Fri 13:06</p>
<p class="validation"><a href="http://validator.w3.org/check?uri=referer">Validate</a></p>
</div>
</body>
diff --git a/README.org b/README.org
index b7da351..40c8a94 100644
--- a/README.org
+++ b/README.org
@@ -137,7 +137,7 @@ 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
+Using the special keyword *config* (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
@@ -149,10 +149,6 @@ Usage:
# /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
diff --git a/res/test-ck b/res/test-ck
index 423d3bd..b1fd51e 100755
--- a/res/test-ck
+++ b/res/test-ck
@@ -15,7 +15,7 @@ function init {
mkdir -p $TEST_LOCATION/vc
mkdir $TEST_LOCATION/sec
- exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null &
+ exec $BIN/ck -c $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null &
wait $!
}
diff --git a/src/actionhelper.c b/src/actionhelper.c
index 6507e7b..6e76b2b 100644
--- a/src/actionhelper.c
+++ b/src/actionhelper.c
@@ -398,3 +398,24 @@ void print_HELP_help() {
ckhelp("Note:\nRunning ck without arguments will print all the available actions.");
report_help();
}
+
+void print_conf_help(void) {
+ ckhelp("Set a different ck configuration directory.\n");
+ ckhelp("This has to be passed before any action or action argument");
+ ckhelp("and after verbose (if set).\n");
+ ckhelp("Usage:");
+ ckhelp(" ck -c /path/to/conf ...");
+ ckhelp(" ck config /path/to/conf ...\n");
+ ckhelp("ck will use the database and config file in the path supplied");
+ ckhelp("to perform any actions.\n");
+ ckhelp("Tip:\nYou can alias `ck -c /path/to/conf` and use the new alias");
+ ckhelp("to organise a different set of configurations, or some custom scrpits.");
+ report_help();
+}
+
+void print_verbose_help(void) {
+ ckhelp("WIP\n");
+ ckhelp("Currently passing the verbose flag, prints a log of what ck is doing");
+ ckhelp("during excecution of an action.");
+ report_help();
+}
diff --git a/src/actionhelper.h b/src/actionhelper.h
index eb544ce..bfe0b85 100644
--- a/src/actionhelper.h
+++ b/src/actionhelper.h
@@ -62,4 +62,7 @@ extern ListOpt list_make_options(cklist *args);
CK_ACTIONS
#undef X
+extern void print_conf_help(void);
+extern void print_verbose_help(void);
+
#endif /* ACTIONHELPER_H */
diff --git a/src/actionparser.c b/src/actionparser.c
index aee9732..7ee46fe 100644
--- a/src/actionparser.c
+++ b/src/actionparser.c
@@ -24,7 +24,7 @@ const char* const strEDIT[] = {"3", "edit", "e", "-e"};
const char* const strLIST[] = {"5", "list", "ls", "l", "-l", "-ls"};
const char* const strSEARCH[] = {"4", "search", "grep", "s", "-s"};
const char* const strHELP[] = {"5", "help", "h", "-?", "-h", "--help"};
-const char* const strConfDir[] = {"4", "config", "conf", "c", "-c"};
+const char* const strConfDir[] = {"2", "config", "-c"};
const char* const strVersion[] = {"2", "version", "--version"};
const char* const strVerbose1[] = {"2", "--verbose", "-v"};
const char* const strVerbose2[] = {"2", "--Verbose", "-V"};
diff --git a/src/actions.c b/src/actions.c
index 417f9ce..fcdf308 100644
--- a/src/actions.c
+++ b/src/actions.c
@@ -281,6 +281,16 @@ int run_HELP(UserOpt *opt, Conf *conf) {
return 0;
}
+ if (strcmp(list_get(opt->args), "config") == 0) {
+ print_conf_help();
+ return 0;
+ }
+
+ if (strcmp(list_get(opt->args), "verbose") == 0) {
+ print_verbose_help();
+ return 0;
+ }
+
switch(parser_get_action(list_get(opt->args), NULL)) {
#define X(ACTION) \
case CKA_##ACTION: \
diff --git a/tests/00_init b/tests/00_init
index 9ea2f1c..1f3f2a6 100644
--- a/tests/00_init
+++ b/tests/00_init
@@ -5,7 +5,7 @@ running init
mkdir -p $TEST_LOCATION/vc
mkdir $TEST_LOCATION/sec
-exec $BIN/ck conf $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null &
+exec $BIN/ck -c $BIN init $TEST_LOCATION/vc $TEST_LOCATION/sec > /dev/null &
wait $!
if [ $? -ne 0 ]; then
diff --git a/tests/01_add b/tests/01_add
index 74c9558..1de64bf 100644
--- a/tests/01_add
+++ b/tests/01_add
@@ -9,7 +9,7 @@ echo "Test 3" > $BIN/test3.conf
function run_add {
# add configs to ck
- exec $BIN/ck conf $BIN add $1 $BIN/$2 $3 $4 > /dev/null &
+ exec $BIN/ck -c $BIN add $1 $BIN/$2 $3 $4 > /dev/null &
wait $!
if [ $? -ne 0 ]; then
diff --git a/tests/02_list b/tests/02_list
index 35bf1ee..e330dad 100644
--- a/tests/02_list
+++ b/tests/02_list
@@ -11,13 +11,13 @@ add_config prog1 $path1
add_config prog2 $path2
add_config prog3 $path3
-for i in $($BIN/ck conf $BIN list paths); do
+for i in $($BIN/ck -c $BIN list paths); do
if [[ "$i" != "$path1" ]] && [[ "$i" != "$path2" ]] && [[ "$i" != "$path3" ]]; then
err "Listing paths"
fi
done
-for i in $($BIN/ck conf $BIN list programs); do
+for i in $($BIN/ck -c $BIN list programs); do
if [[ "$i" != "prog1" ]] && [[ "$i" != "prog2" ]] && [[ "$i" != "prog3" ]]; then
err "Listing programs"
fi
diff --git a/tests/03_delete b/tests/03_delete
index ee1cdd6..1668576 100644
--- a/tests/03_delete
+++ b/tests/03_delete
@@ -15,10 +15,10 @@ add_config prog2 $path3
add_config prog2 $path4
# delete path1
-exec $BIN/ck conf $BIN del -c $path1 > /dev/null &
+exec $BIN/ck -c $BIN del -c $path1 > /dev/null &
wait $!
-for i in $($BIN/ck conf $BIN list paths); do
+for i in $($BIN/ck -c $BIN list paths); do
if [[ "$i" == "$path1" ]]; then
err "Couldn't delete path."
exit 1
@@ -26,26 +26,26 @@ for i in $($BIN/ck conf $BIN list paths); do
done
# delete path2 (also prog1)
-exec $BIN/ck conf $BIN del -c $path2 > /dev/null &
+exec $BIN/ck -c $BIN del -c $path2 > /dev/null &
wait $!
-for i in $($BIN/ck conf $BIN list programs); do
+for i in $($BIN/ck -c $BIN list programs); do
if [[ "$i" == "prog1" ]]; then
err "Removing all configs should delete the correspondig program."
fi
done
# delete prog2
-exec $BIN/ck conf $BIN del prog2 > /dev/null &
+exec $BIN/ck -c $BIN del prog2 > /dev/null &
wait $!
-for i in $($BIN/ck conf $BIN list paths); do
+for i in $($BIN/ck -c $BIN list paths); do
if [[ "$i" == "$path3" ]] || [[ "$i" == "$path4" ]]; then
err "Removing the program should delete all it's configs."
fi
done
-for i in $($BIN/ck conf $BIN list programs); do
+for i in $($BIN/ck -c $BIN list programs); do
if [[ "$i" == "prog1" ]]; then
err "Couldn't remove program."
fi
diff --git a/tests/04_search b/tests/04_search
index 9f3d2e5..c3600c1 100644
--- a/tests/04_search
+++ b/tests/04_search
@@ -14,7 +14,7 @@ add_config prog2 $path3 "search-term"
add_config prog3 $path4 "search-term"
# delete path1
-if [[ $($BIN/ck conf $BIN search search-term | wc -l) != 4 ]]; then
+if [[ $($BIN/ck -c $BIN search search-term | wc -l) != 4 ]]; then
err "search failed."
fi