aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgramanas <anastasis.gramm2@gmail.com>2018-11-20 20:21:29 +0200
committergramanas <anastasis.gramm2@gmail.com>2018-11-20 20:21:29 +0200
commitbd85acf6a408674bcdcb5116963fe4fea2247280 (patch)
tree4318ff7e1331b16cb9152f45601eedb89b30fb92
parentda31bfd28301d63571eccb4abdd6b0a65b05c621 (diff)
downloadck-bd85acf6a408674bcdcb5116963fe4fea2247280.tar.gz
ck-bd85acf6a408674bcdcb5116963fe4fea2247280.tar.bz2
ck-bd85acf6a408674bcdcb5116963fe4fea2247280.zip
Simplyfy restore arguments
-rw-r--r--CMakeLists.txt2
-rw-r--r--README.html253
-rw-r--r--README.org55
-rw-r--r--ck.114
-rw-r--r--src/clparser.h2
-rw-r--r--src/confparser.c2
-rw-r--r--src/restore.c37
-rw-r--r--test/restore.sh4
8 files changed, 245 insertions, 124 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ce41ade..8dcf30a 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 4)
+set(ck_PATCH_VERSION 5)
# Feature test macros
set(FEATURE_TEST_MACROS "-D_DEFAULT_SOURCE")
diff --git a/README.html b/README.html
index 6c38c37..215584d 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-11-20 Tue 13:48 -->
+<!-- 2018-11-20 Tue 20:21 -->
<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,36 +232,37 @@ for the JavaScript code in this tag.
<h2>Table of Contents</h2>
<div id="text-table-of-contents">
<ul>
-<li><a href="#org10db10e">ck</a>
+<li><a href="#org0e0ea28">ck</a>
<ul>
-<li><a href="#orgd5becfe">Technicalities</a></li>
-<li><a href="#org9006d02">Download</a></li>
+<li><a href="#org75bd278">Technicalities</a></li>
+<li><a href="#org7b74163">Download</a></li>
</ul>
</li>
<li><a href="#build-instructions">build it</a>
<ul>
-<li><a href="#org111dea7">requirements</a></li>
-<li><a href="#org887e970">make &amp;&amp; install</a></li>
+<li><a href="#org7418c21">requirements</a></li>
+<li><a href="#org8552dd5">make &amp;&amp; install</a></li>
</ul>
</li>
-<li><a href="#org90d0470">for devs</a>
+<li><a href="#org5c96039">for devs</a>
<ul>
-<li><a href="#orgb40d88b">CMake options</a></li>
-<li><a href="#org8004748">compiler</a></li>
-<li><a href="#org206a328">tests</a>
+<li><a href="#org82929b2">CMake options</a></li>
+<li><a href="#org727ad65">compiler</a></li>
+<li><a href="#org64d45ce">tests</a>
<ul>
-<li><a href="#org9934a6f">run tests</a></li>
-<li><a href="#org91a2119">test suite</a></li>
+<li><a href="#org7eef031">run tests</a></li>
+<li><a href="#org00a6b39">test suite</a></li>
</ul>
</li>
</ul>
</li>
-<li><a href="#orgc85202a">ck configuration</a></li>
+<li><a href="#orge40edff">ck configuration</a></li>
<li><a href="#usage">Usage</a>
<ul>
-<li><a href="#org5123075">Initialize</a></li>
-<li><a href="#orga15fbdd">Add configs</a></li>
-<li><a href="#orgf2b924a">Using the ck actions</a></li>
+<li><a href="#org498e586">Initialize</a></li>
+<li><a href="#orged99083">Add configs</a></li>
+<li><a href="#orge5ed33e">Using the ck actions</a></li>
+<li><a href="#org188208d">Copying configs to a different linux system</a></li>
</ul>
</li>
<li><a href="#manpage">manpage</a></li>
@@ -269,9 +270,9 @@ for the JavaScript code in this tag.
</div>
</div>
<p align="center"><img src="res/logo.png"></p>
-<div id="outline-container-org10db10e" class="outline-2">
-<h2 id="org10db10e">ck</h2>
-<div class="outline-text-2" id="text-org10db10e">
+<div id="outline-container-org0e0ea28" class="outline-2">
+<h2 id="org0e0ea28">ck</h2>
+<div class="outline-text-2" id="text-org0e0ea28">
<p>
<b>The Config Keeper</b>
</p>
@@ -332,9 +333,9 @@ You can even export all <b>ck</b> data with the <code>export</code> action. This
</p>
</div>
-<div id="outline-container-orgd5becfe" class="outline-3">
-<h3 id="orgd5becfe">Technicalities</h3>
-<div class="outline-text-3" id="text-orgd5becfe">
+<div id="outline-container-org75bd278" class="outline-3">
+<h3 id="org75bd278">Technicalities</h3>
+<div class="outline-text-3" id="text-org75bd278">
<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>).
@@ -347,9 +348,9 @@ majority should).
</div>
</div>
-<div id="outline-container-org9006d02" class="outline-3">
-<h3 id="org9006d02">Download</h3>
-<div class="outline-text-3" id="text-org9006d02">
+<div id="outline-container-org7b74163" class="outline-3">
+<h3 id="org7b74163">Download</h3>
+<div class="outline-text-3" id="text-org7b74163">
<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.
@@ -367,13 +368,13 @@ You can also read the manpage <a href="#manpage">down below</a>.
</div>
</div>
-<div id="outline-container-org7d912d3" class="outline-2">
-<h2 id="build-instructions"><a id="org7d912d3"></a>build it</h2>
+<div id="outline-container-org5a78f5e" class="outline-2">
+<h2 id="build-instructions"><a id="org5a78f5e"></a>build it</h2>
<div class="outline-text-2" id="text-build-instructions">
</div>
-<div id="outline-container-org111dea7" class="outline-3">
-<h3 id="org111dea7">requirements</h3>
-<div class="outline-text-3" id="text-org111dea7">
+<div id="outline-container-org7418c21" class="outline-3">
+<h3 id="org7418c21">requirements</h3>
+<div class="outline-text-3" id="text-org7418c21">
<ul class="org-ul">
<li>cmake</li>
<li>sqlite3-dev</li>
@@ -382,9 +383,9 @@ You can also read the manpage <a href="#manpage">down below</a>.
</div>
</div>
-<div id="outline-container-org887e970" class="outline-3">
-<h3 id="org887e970">make &amp;&amp; install</h3>
-<div class="outline-text-3" id="text-org887e970">
+<div id="outline-container-org8552dd5" class="outline-3">
+<h3 id="org8552dd5">make &amp;&amp; install</h3>
+<div class="outline-text-3" id="text-org8552dd5">
<p>
Use <code>-DCMAKE_INSTALL_PREFIX</code> when running cmake to change the install path.
</p>
@@ -394,7 +395,7 @@ Use <code>-DCMAKE_INSTALL_PREFIX</code> when running cmake to change the install
<span style="color: #656565;"># </span><span style="color: #757575;">make a build directory and enter it</span>
&gt; mkdir ~/ck_build; <span style="color: #528fd1;">cd</span> ~/ck_build;
<span style="color: #656565;"># </span><span style="color: #757575;">run cmake</span>
-&gt; cmake ~/code/ck
+&gt; cmake ~/code/ck
<span style="color: #656565;"># </span><span style="color: #757575;">run make</span>
&gt; make
<span style="color: #656565;"># </span><span style="color: #757575;">install it</span>
@@ -407,16 +408,16 @@ Use <code>-DCMAKE_INSTALL_PREFIX</code> when running cmake to change the install
</div>
</div>
-<div id="outline-container-org90d0470" class="outline-2">
-<h2 id="org90d0470">for devs</h2>
-<div class="outline-text-2" id="text-org90d0470">
+<div id="outline-container-org5c96039" class="outline-2">
+<h2 id="org5c96039">for devs</h2>
+<div class="outline-text-2" id="text-org5c96039">
<p>
Please be <a href="https://www.gnu.org/philosophy/kind-communication.html">kind</a> to each other.
</p>
</div>
-<div id="outline-container-orgb40d88b" class="outline-3">
-<h3 id="orgb40d88b">CMake options</h3>
-<div class="outline-text-3" id="text-orgb40d88b">
+<div id="outline-container-org82929b2" class="outline-3">
+<h3 id="org82929b2">CMake options</h3>
+<div class="outline-text-3" id="text-org82929b2">
<p>
cmake accepts the following options:
</p>
@@ -437,9 +438,9 @@ To use any one of them append it after the cmake command like so:
</div>
</div>
-<div id="outline-container-org8004748" class="outline-3">
-<h3 id="org8004748">compiler</h3>
-<div class="outline-text-3" id="text-org8004748">
+<div id="outline-container-org727ad65" class="outline-3">
+<h3 id="org727ad65">compiler</h3>
+<div class="outline-text-3" id="text-org727ad65">
<p>
Pick your favorite
</p>
@@ -469,9 +470,9 @@ Pick your favorite
</div>
</div>
-<div id="outline-container-org206a328" class="outline-3">
-<h3 id="org206a328">tests</h3>
-<div class="outline-text-3" id="text-org206a328">
+<div id="outline-container-org64d45ce" class="outline-3">
+<h3 id="org64d45ce">tests</h3>
+<div class="outline-text-3" id="text-org64d45ce">
<p>
The testing "suite" is a bash script that runs regression
and unit tests. Regression tests are under the <code>tests/</code> directory
@@ -480,9 +481,9 @@ under <code>unit/</code> directory and test the code.
</p>
</div>
-<div id="outline-container-org9934a6f" class="outline-4">
-<h4 id="org9934a6f">run tests</h4>
-<div class="outline-text-4" id="text-org9934a6f">
+<div id="outline-container-org7eef031" class="outline-4">
+<h4 id="org7eef031">run tests</h4>
+<div class="outline-text-4" id="text-org7eef031">
<p>
First make sure you build ck with the <code>-DCK_TESTS=1</code> option. Then
go to the build directory and type:
@@ -505,9 +506,9 @@ This will match any test scrits with <code>add</code> in their name.
</div>
-<div id="outline-container-org91a2119" class="outline-4">
-<h4 id="org91a2119">test suite</h4>
-<div class="outline-text-4" id="text-org91a2119">
+<div id="outline-container-org00a6b39" class="outline-4">
+<h4 id="org00a6b39">test suite</h4>
+<div class="outline-text-4" id="text-org00a6b39">
<div class="org-src-container">
<pre class="src src-sh">$ ./test-ck -h
ck test suite
@@ -527,17 +528,17 @@ flags:
</div>
</div>
</div>
-<div id="outline-container-orgc85202a" class="outline-2">
-<h2 id="orgc85202a">ck configuration</h2>
-<div class="outline-text-2" id="text-orgc85202a">
+<div id="outline-container-orge40edff" class="outline-2">
+<h2 id="orge40edff">ck configuration</h2>
+<div class="outline-text-2" id="text-orge40edff">
<p>
See the <a href="#manpage">manpage</a> below.
</p>
</div>
</div>
-<div id="outline-container-org0ed22f1" class="outline-2">
-<h2 id="usage"><a id="org0ed22f1"></a>Usage</h2>
+<div id="outline-container-org3eb4040" class="outline-2">
+<h2 id="usage"><a id="org3eb4040"></a>Usage</h2>
<div class="outline-text-2" id="text-usage">
<p>
ck's goal is to assist with the configuration file management.
@@ -547,9 +548,9 @@ ck's goal is to assist with the configuration file management.
This section is an example usage.
</p>
</div>
-<div id="outline-container-org5123075" class="outline-3">
-<h3 id="org5123075">Initialize</h3>
-<div class="outline-text-3" id="text-org5123075">
+<div id="outline-container-org498e586" class="outline-3">
+<h3 id="org498e586">Initialize</h3>
+<div class="outline-text-3" id="text-org498e586">
<div class="org-src-container">
<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>
@@ -562,9 +563,9 @@ $ ck init configs/vc configs/sec
</div>
</div>
-<div id="outline-container-orga15fbdd" class="outline-3">
-<h3 id="orga15fbdd">Add configs</h3>
-<div class="outline-text-3" id="text-orga15fbdd">
+<div id="outline-container-orged99083" class="outline-3">
+<h3 id="orged99083">Add configs</h3>
+<div class="outline-text-3" id="text-orged99083">
<div class="org-src-container">
<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>
@@ -592,9 +593,9 @@ $ sudo ck -c /home/ckuser add ssh /etc/ssh/sshd_config -s
</div>
</div>
-<div id="outline-container-orgf2b924a" class="outline-3">
-<h3 id="orgf2b924a">Using the ck actions</h3>
-<div class="outline-text-3" id="text-orgf2b924a">
+<div id="outline-container-orge5ed33e" class="outline-3">
+<h3 id="orge5ed33e">Using the ck actions</h3>
+<div class="outline-text-3" id="text-orge5ed33e">
<div class="org-src-container">
<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
@@ -633,9 +634,9 @@ $ ck delete emacs
$ ck del emacs init.el
<span style="color: #656565;"># </span><span style="color: #757575;">restore all links (on a new instalation)</span>
-$ ck restore all
+$ ck restore --all
<span style="color: #656565;"># </span><span style="color: #757575;">restore a program's links</span>
-$ ck r -p emacs
+$ ck r emacs
<span style="color: #656565;"># </span><span style="color: #757575;">get help for an action</span>
$ ck h add
@@ -644,13 +645,99 @@ $ ck --help e
</div>
</div>
</div>
+
+<div id="outline-container-org188208d" class="outline-3">
+<h3 id="org188208d">Copying configs to a different linux system</h3>
+<div class="outline-text-3" id="text-org188208d">
+<p>
+Using the method described below one can use ck
+to copy the configs to a different linux system.
+In this example we assume we have the ck instance we created
+above and we want to copy some configs to our new VPS.
+</p>
+
+<p>
+We will also assume that the VPS' username is different
+that the one on our desktop (<code>ckuser</code> in our example).
+</p>
+</div>
+
+<ul class="org-ul">
+<li><a id="org47ab060"></a>Start at the desktop by exporting the ck files<br />
+<div class="outline-text-5" id="text-org47ab060">
+<div class="org-src-container">
+<pre class="src src-sh">you@desktop -&gt; ck export
+</pre>
+</div>
+</div>
+</li>
+
+<li><a id="org129ddcb"></a>Copy the resulting tar file to the server<br />
+<div class="outline-text-5" id="text-org129ddcb">
+<div class="org-src-container">
+<pre class="src src-sh">you@desktop -&gt; scp ck.tar.gz ckuser@server:/home/ckuser
+</pre>
+</div>
+</div>
+</li>
+
+<li><a id="org11d79a3"></a>Now we ssh to the server<br />
+<div class="outline-text-5" id="text-org11d79a3">
+<div class="org-src-container">
+<pre class="src src-sh">you@desktop -&gt; ssh ckuser@server
+</pre>
+</div>
+</div>
+</li>
+
+<li><a id="orgf935871"></a>Start by untaring the archive &amp; installing ck<br />
+<div class="outline-text-5" id="text-orgf935871">
+<div class="org-src-container">
+<pre class="src src-sh">ckuser@server -&gt; tar zxf ck.tar.gz
+</pre>
+</div>
+</div>
+</li>
+
+<li><a id="org3387d36"></a>Move the <i><i>version_control_dir</i></i> and <i><i>secer_dir</i></i> to where you want them to be<br /></li>
+<li><a id="orge754263"></a>Move the <i><i>ckrc</i></i> and <i><i>ckdb</i></i> files where you want ck config home to be<br /></li>
+<li><a id="org494b09d"></a>Edit <i><i>ckrc</i></i> and change the <b>home_dir</b> to /home/ckuser<br /></li>
+<li><a id="orgb534be5"></a>Also change <i><i>secret_dir</i></i> and <i><i>version_control_dir</i></i> to where you placed them before<br /></li>
+<li><a id="org647fa34"></a>Make sure ck will find your config by default by setting the $CK_CONFIG environment variable<br />
+<div class="outline-text-5" id="text-org647fa34">
+<p>
+Edit bashrc to make this permanent.
+</p>
+<div class="org-src-container">
+<pre class="src src-sh">ckuser@server -&gt; export <span style="color: #baba36;">CK_CONFIG</span>=/where/you/have/ckrc/and/ckdb
+</pre>
+</div>
+
+<p>
+Note, you might not have to use this if you use one of the default config locations.
+ck will first check $XDG_CONFIG_HOME/ck and then $HOME/.ck so using either one of these will do.
+</p>
+</div>
+</li>
+<li><a id="org9fe13ce"></a>Remove any existing conflicting configs<br /></li>
+<li><a id="orgf0586c6"></a>Restore your configs<br />
+<div class="outline-text-5" id="text-orgf0586c6">
+<div class="org-src-container">
+<pre class="src src-sh">ckuser@server -&gt; ck restore zsh
+ckuser@server -&gt; ck restore emacs
+</pre>
+</div>
+</div>
+</li>
+</ul>
+</div>
</div>
-<div id="outline-container-org4efb467" class="outline-2">
-<h2 id="manpage"><a id="org4efb467"></a>manpage</h2>
+<div id="outline-container-org6964442" class="outline-2">
+<h2 id="manpage"><a id="org6964442"></a>manpage</h2>
<div class="outline-text-2" id="text-manpage">
<!-- Creator : groff version 1.22.3 -->
-<!-- CreationDate: Tue Nov 20 13:48:12 2018 -->
+<!-- CreationDate: Tue Nov 20 20:21:23 2018 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
@@ -882,7 +969,7 @@ manage configuration across the system</p>
<td width="82%">
-<p><b>restore &minus;p</b> <i>PROGRAM_NAME</i></p></td>
+<p><b>restore</b> <i>PROGRAM_NAME</i></p></td>
<td width="3%">
</td></tr>
<tr valign="top" align="left">
@@ -895,7 +982,7 @@ manage configuration across the system</p>
<td width="82%">
-<p><b>restore all</b></p></td>
+<p><b>restore &minus;&minus;all</b></p></td>
<td width="3%">
</td></tr>
<tr valign="top" align="left">
@@ -1700,11 +1787,11 @@ USAGE</b></p>
<p><b>ck</b></p></td>
<td width="1%"></td>
-<td width="36%">
+<td width="31%">
-<p><b>restore &minus;p</b> <i>PROGRAM_NAME</i></p></td>
-<td width="46%">
+<p><b>restore</b> <i>PROGRAM_NAME</i></p></td>
+<td width="51%">
</td></tr>
<tr valign="top" align="left">
<td width="14%"></td>
@@ -1713,11 +1800,11 @@ USAGE</b></p>
<p><b>ck</b></p></td>
<td width="1%"></td>
-<td width="36%">
+<td width="31%">
-<p><b>restore all</b></p></td>
-<td width="46%">
+<p><b>restore &minus;&minus;all</b></p></td>
+<td width="51%">
</td></tr>
</table>
@@ -1746,7 +1833,7 @@ USAGE</b></p>
<td width="18%">
-<p><b>all</b></p></td>
+<p><b>--all</b></p></td>
<td width="14%"></td>
<td width="54%">
@@ -1756,8 +1843,8 @@ USAGE</b></p>
<p style="margin-left:11%;"><b>EXAMPLES</b></p>
-<pre style="margin-left:14%;">$ ck restore all
-$ ck restore -p emacs</pre>
+<pre style="margin-left:14%;">$ ck restore --all
+$ ck restore emacs</pre>
<p style="margin-left:11%; margin-top: 1em"><b>GET HELP</b>
@@ -1936,7 +2023,7 @@ flags</b>: @CMAKE_C_FLAGS@</p>
</div>
</div>
<div id="postamble" class="status">
-<p class="date">Created: 2018-11-20 Tue 13:48</p>
+<p class="date">Created: 2018-11-20 Tue 20:21</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 fb15d30..ce1f4e9 100644
--- a/README.org
+++ b/README.org
@@ -69,7 +69,7 @@ Use =-DCMAKE_INSTALL_PREFIX= when running cmake to change the install path.
# make a build directory and enter it
> mkdir ~/ck_build; cd ~/ck_build;
# run cmake
- > cmake ~/code/ck
+ > cmake ~/code/ck
# run make
> make
# install it
@@ -235,15 +235,64 @@ This section is an example usage.
$ ck del emacs init.el
# restore all links (on a new instalation)
- $ ck restore all
+ $ ck restore --all
# restore a program's links
- $ ck r -p emacs
+ $ ck r emacs
# get help for an action
$ ck h add
$ ck --help e
#+END_SRC
+** Copying configs to a different linux system
+
+Using the method described below one can use ck
+to copy the configs to a different linux system.
+In this example we assume we have the ck instance we created
+above and we want to copy some configs to our new VPS.
+
+We will also assume that the VPS' username is different
+that the one on our desktop (=ckuser= in our example).
+
+**** Start at the desktop by exporting the ck files
+#+BEGIN_SRC sh
+ you@desktop -> ck export
+#+END_SRC
+
+**** Copy the resulting tar file to the server
+#+BEGIN_SRC sh
+ you@desktop -> scp ck.tar.gz ckuser@server:/home/ckuser
+#+END_SRC
+
+**** Now we ssh to the server
+#+BEGIN_SRC sh
+ you@desktop -> ssh ckuser@server
+#+END_SRC
+
+**** Start by untaring the archive & installing ck
+#+BEGIN_SRC sh
+ ckuser@server -> tar zxf ck.tar.gz
+#+END_SRC
+
+**** Move the //version_control_dir// and //secer_dir// to where you want them to be
+**** Move the //ckrc// and //ckdb// files where you want ck config home to be
+**** Edit //ckrc// and change the *home_dir* to /home/ckuser
+**** Also change //secret_dir// and //version_control_dir// to where you placed them before
+**** Make sure ck will find your config by default by setting the $CK_CONFIG environment variable
+ Edit bashrc to make this permanent.
+ #+BEGIN_SRC sh
+ ckuser@server -> export CK_CONFIG=/where/you/have/ckrc/and/ckdb
+ #+END_SRC
+
+ Note, you might not have to use this if you use one of the default config locations.
+ ck will first check $XDG_CONFIG_HOME/ck and then $HOME/.ck so using either one of these will do.
+**** Remove any existing conflicting configs
+**** Restore your configs
+#+BEGIN_SRC sh
+ ckuser@server -> ck restore zsh
+ ckuser@server -> ck restore emacs
+#+END_SRC
+
* manpage
:PROPERTIES:
:CUSTOM_ID: manpage
diff --git a/ck.1 b/ck.1
index 020242d..827b7ce 100644
--- a/ck.1
+++ b/ck.1
@@ -80,12 +80,12 @@ ck \- manage configuration across the system
.YS
\" Restore
.SY ck
-.B restore \-p
+.B restore
.I PROGRAM_NAME
.YS
.ns
.SY ck
-.B restore all
+.B restore \-\-all
.YS
\" Help
.SY ck
@@ -714,12 +714,12 @@ take care of the already created links, if that's the case.
.ns
.RS 2
.SY ck
-.B restore \-p
+.B restore
.I PROGRAM_NAME
.YS
.ns
.SY ck
-.B restore all
+.B restore \-\-all
.YS
.RE
.TP 2
@@ -735,7 +735,7 @@ The name of the
.B program
to be restored.
.TP 21
-.B all
+.B --all
Restore all
.B programs ck
keeps track of.
@@ -743,8 +743,8 @@ keeps track of.
.TP 2
.B EXAMPLES
.EX
-$ ck restore all
-$ ck restore -p emacs
+$ ck restore --all
+$ ck restore emacs
.EE
.SS "GET HELP"
Get help for any given
diff --git a/src/clparser.h b/src/clparser.h
index 6e4cbea..1ba6d00 100644
--- a/src/clparser.h
+++ b/src/clparser.h
@@ -28,7 +28,7 @@
X(EDIT, 1, 5) \
X(LIST, 1, 6) \
X(SEARCH, 1, 1) \
- X(RESTORE, 1, 2) \
+ X(RESTORE, 1, 1) \
X(EXPORT, 0, 0) \
X(HELP, 1, 1)
diff --git a/src/confparser.c b/src/confparser.c
index 48f0c71..f7b6268 100644
--- a/src/confparser.c
+++ b/src/confparser.c
@@ -88,7 +88,7 @@ int find_config(UserOpt *opt) {
return 0;
}
}
- LOG("$XDG_CONFIG_HOME not avaliable.");
+ ERR("No config found.");
return -1;
}
diff --git a/src/restore.c b/src/restore.c
index a18f906..426e803 100644
--- a/src/restore.c
+++ b/src/restore.c
@@ -129,44 +129,29 @@ int run_RESTORE(UserOpt *opt, Conf *conf) {
cklist *from = list_make_new();
cklist *to = list_make_new();
int err_flag = 0;
- if (strcmp(list_get(opt->args), "-p") == 0) {
- if (list_next(opt->args)) {
- if (program_exists(&db, list_get(opt->args))) {
- if (restore_configs_exists(&db, conf, list_get(opt->args), from, to)) {
- hLOG("Restoring links for %s...", list_get(opt->args));
- }
- else {
- err_flag = 1;
- }
+ char *arg = list_get(opt->args);
+ if (strcmp(arg, "--all") != 0) {
+ if (program_exists(&db, arg)) {
+ if (restore_configs_exists(&db, conf, arg, from, to)) {
+ hLOG("Restoring links for %s...", arg);
}
else {
- ERR("Program %s does not exist", list_get(opt->args));
err_flag = 1;
}
}
else {
- sERR("-p needs a program name");
+ ERR("Program %s does not exist", arg);
err_flag = 1;
}
}
- else if (strcmp(list_get(opt->args), "all") == 0) {
- if (!list_next(opt->args)) {
- if (restore_all_exist(&db, conf, from, to)) {
- hLOG("Restoring all links...");
- }
- else {
- err_flag = 1;
- }
+ else {
+ if (restore_all_exist(&db, conf, from, to)) {
+ hLOG("Restoring all links...");
}
else {
- sERR("Wrong argument");
err_flag = 1;
}
}
- else {
- sERR("Wrong argument");
- err_flag = 1;
- }
close_DB(&db);
int rc = -1;
if (!err_flag) {
@@ -181,7 +166,7 @@ int run_RESTORE(UserOpt *opt, Conf *conf) {
}
void print_RESTORE_help() {
- ckhelp("ck restore -p PROGRAM_NAME");
- ckhelp("ck restore all");
+ ckhelp("ck restore PROGRAM_NAME");
+ ckhelp("ck restore --all");
report_help();
}
diff --git a/test/restore.sh b/test/restore.sh
index ba131e4..3730fb2 100644
--- a/test/restore.sh
+++ b/test/restore.sh
@@ -18,7 +18,7 @@ add_config prog2 $path4
rm "$path1" "$path2"
# restore them
-exec $BIN/ck -c $BIN restore -p prog1 >&${V} &
+exec $BIN/ck -c $BIN restore prog1 >&${V} &
wait $!
for i in $($BIN/ck -c $BIN list -p prog1); do
@@ -32,7 +32,7 @@ done
rm "$path1" "$path2" "$path3" "$path4"
# restore all
-exec $BIN/ck -c $BIN restore all >&${V} &
+exec $BIN/ck -c $BIN restore --all >&${V} &
wait $!
for i in $($BIN/ck -c $BIN list paths); do