From 5683c51d17b5eed7d2f070aa4e49cc21b65d82e5 Mon Sep 17 00:00:00 2001 From: gramanas Date: Mon, 29 Oct 2018 17:20:28 +0200 Subject: Add list with basename and update readme --- README.html | 657 ++++++++++++++++++++---------------------------------------- 1 file changed, 214 insertions(+), 443 deletions(-) (limited to 'README.html') diff --git a/README.html b/README.html index f6bd550..655204c 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -232,53 +232,46 @@ for the JavaScript code in this tag.

Table of Contents

-
-

ck

-
+
+

ck

+

The Config Keeper

@@ -334,9 +327,9 @@ with the rest of us).

-
-

Technicalities

-
+
+

Technicalities

+

Upon adding a config to ck, it moves it to the specified folder and adds a symbolic link back where it came from (ln -s). @@ -349,9 +342,9 @@ majority should).

-
-

Download

-
+
+

Download

+

Go ahead and download ck and give it a try. It comes with a help sub-command that explains any inquires you might have. @@ -363,19 +356,19 @@ the build section.

-You can also read the manual down below. +You can also read the manpage down below.

-
-

build it

+
+

build it

-
-

requirements

-
+
+

requirements

+
  • cmake
  • sqlite3-dev
  • @@ -384,24 +377,24 @@ You can also read the manual down below.
-
-

make && install

-
+
+

make && install

+

Use -DCMAKE_INSTALL_PREFIX when running cmake to change the install path.

-
# clone the repo
+
# clone the repo
 > cd ~/code; git clone https://gitlab.com/grm-grm/ck
-# make a build directory and enter it
-> mkdir ~/ck_build; cd ~/ck_build;
-# run cmake
+# make a build directory and enter it
+> mkdir ~/ck_build; cd ~/ck_build;
+# run cmake
 > cmake ~/code/ck 
-# run make
+# run make
 > make
-# install it
+# install it
 > make install
-# run ck
+# run ck
 > ck
 
@@ -409,23 +402,23 @@ Use -DCMAKE_INSTALL_PREFIX when running cmake to change the install
-
-

for devs

-
+
+

for devs

+

Please be kind to each other.

-
-

CMake options

-
+
+

CMake options

+

cmake accepts the following options:

-
option(CK_DEBUG "Build with debug symbols, asan and warnings")
-option(CK_TESTS "Make the tests")
-option(CK_SHARED "Build with shared lib")
+
option(CK_DEBUG "Build with debug symbols, asan and warnings")
+option(CK_TESTS "Make the tests")
+option(CK_SHARED "Build with shared lib")
 
@@ -439,41 +432,41 @@ To use any one of them append it after the cmake command like so:
-
-

compiler

-
+
+

compiler

+

Pick your favorite

-
> export CC=clang
-# or
-> export CC=gcc
+
> export CC=clang
+# or
+> export CC=gcc
 
-
# clone the repo
+
# clone the repo
 > cd ~/code; git clone https://gitlab.com/grm-grm/ck
-# make a build directory and enter it
-> mkdir ~/ck_build; cd ~/ck_build;
-# run cmake
+# make a build directory and enter it
+> mkdir ~/ck_build; cd ~/ck_build;
+# run cmake
 > cmake -DCK_DEBUG=1 -DCK_TESTS=1 ~/code/ck
-# run make
+# run make
 > make
-# check ck
+# check ck
 > ./test-ck
-# run ck
+# run ck
 > ./ck
 
-
-

tests

-
+
+

tests

+

The testing "suite" is a bash script that runs regression and unit tests. Regression tests are under the tests/ directory @@ -482,9 +475,9 @@ under unit/ directory and test the code.

-
-

run tests

-
+
+

run tests

+

First make sure you build ck with the -DCK_TESTS=1 option. Then go to the build directory and type: @@ -496,9 +489,9 @@ go to the build directory and type:

-
-

test suite

-
+
+

test suite

+
$ ./test-ck -h
 ck test suite
@@ -516,400 +509,124 @@ flags:
 
-
-

manual

-
-

-ck's goal is to assist with the configuration file management. -To that end it tries to provides a cli interface that is pretty straight-forward -and intuitive. -

- +
+

ck configuration

+

-Example usage: +See the manpage below.

-
-
# initialize new ck
-$ ck init /path_to/where_you_want/your_configs/to_be \
-  /path_to/the_secret/directory
-
-# add emacs configs
-## primary config
-$ ck add emacs ~/.emacs.d/orgconf.org -p
-## secret config, with passwords and naughty words
-$ ck add emacs ~/.emacs.d/accounts.org -s
-## and another one for emacs
-$ ck add emacs ~/.emacs.d/init.el
-
-# add tmux config
-$ ck add tmux ~/.tmux.conf -p
-
-# list the configs
-$ ck list tree
-$ ck list paths -t lisp
-$ ck list programs -t python
-$ ck list -p emacs
-
-# search the configs
-$ ck search search-term
-$ ck search "\"search term with spaces\""
-$ ck search "\(" #escape symbols
-
- -

-The first command after typing ck is the action you wish to perform. Actions are -a very important concept of ck. With an action you can initialize ck, add/delete -configuration files to/from it, edit them, list them in various ways and search in their content. -

- -

-Actions expect their arguments in the order specified below. This is done to reduce the amount -of flags one has to pass to ck. -

-
-

ck configuration

-
-

-ck uses sqlite to index the configuration files. The init -action creates a .ck directory (under $HOME) -in witch the ckrc and the ckdb reside. The first one contains -the two directories described above while the other one is the -sqlite db. -

- -

-One can have multiple config directories with different configurations -each. -

- +
+

Usage

+

-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 -directory of your choice. +ck's goal is to assist with the configuration file management.

-Usage: +This section is an example usage.

-
-
$ ck config ~/ ... # the default behaviour
-
-# /someplace/else must exist or
-# the action following it must be init
-$ ck -c /someplace/else ... 
-
-
-
- -
-

Actions

-
-
-
-

init

-
-

-or i or -i -

- -

-init takes exactly 2 arguments. -

- -
    -
  • config_dir: where all the configs will live
  • -
  • secret_dir: where all the secret configs will live
  • -
- -

-Use init to initialize a new ck database. -

- -

-Usage: -

+
+

Initialize

+
-
# initialize new ck
-$ ck init /path_to/where_you_want/your_configs/to_be \
-  /path_to/the_secret/directory
-
-
-
-
- -
-

add

-
-

-or a or -a -

- -

-Adds a configuration to the ck database. -Add takes 2 to 4 arguments. -

- -
    -
  • program_name: the name of the program you add a config to
  • -
  • config_path: the path to the config
  • -
  • Optional: (order doesn't matter) -
      -
    • -p: the config will be the primary (relevant on edit below)
    • -
    • -s: the config will be stored in the secret_dir
    • -
  • -
- -

-Keep in mind: -

-
    -
  • The config has to exist.
  • -
  • If you are adding a config to a program already existing in ckdb make -sure to use the same name.
  • -
  • Each program can have only one primary config.
  • -
+
cd ~
+# make the directories for the configs
+$ mkdir -p configs/vc configs/sec
 
-

-Usage: -

-
-
# add config to ck
-$ ck add program_name config_path [-s] [-p]
+# initialize new ck
+$ ck init configs/vc configs/sec
 
-
-

list

-
-

-or ls or l or -l -

- -

-List stuff ck knows about. -

- -

-You can use the keywords: -

-
    -
  • paths: to print all the paths ck tracks
  • -
  • programs: to print all the programs ck tracks
  • -
  • -p progName: (without the "<>") to print the paths of a specific program
  • -
- -

-With the flag -t and then one of the follwing types one can change -the way the list is printed: -

-
    -
  • plain: simple listing (default)
  • -
  • python: print like a python list
  • -
  • lisp: print like a lisp list
  • -
- -

-Using the keyword tree ck can list the configurations under their -corresponding program, in a treelike structure. -

- -

-Passing the -a flag will enable the listing of config attributes (secret or primary). -It is best used with tree or plain paths. -

- -

-With the keyword ckconf ck will list it's own configuration values (in ckrc). -

- -

-Usage: -

+
+

Add configs

+
-
# list tree structure, with attributes
-$ ck list tree -a
-# list paths in python
-$ ck l paths -t python
-# list programs in lisp
-$ ck ls programs -t lisp
-# list emacs' configurations [with attributes]
-$ ck ls -p emacs [-a]
-# list bash configurations in lisp
-$ ck ls -p bash -t lisp
-# list ck configuration
-$ ck -l ckconf
+
# add emacs configs
+## primary config
+$ ck add emacs .emacs.d/orgconf.org -p
+## secret config, with passwords and naughty words
+$ ck add emacs .emacs.d/accounts.org -s
+## and another one for emacs
+$ ck add emacs .emacs.d/init.el
+
+# add tmux config
+$ ck add tmux .tmux.conf -p
+
+# add X configs
+$ ck add X .xinitrc
+$ ck add X .Xresources
+
+# add ssh configs (secret)
+$ ck add ssh .ssh/config -s -p
+$ ck add ssh .ssh/authorized_keys -s
+# When running with sudo, we need to specify the ck config
+# location.
+$ sudo ck -c /home/ckuser add ssh /etc/ssh/sshd_config -s
 
-
-

search

-
-

-or grep or s or -s -

- -

-Perform infile grep in all the configurations ck keeps track of. -

- -

-Takes one argument, the search-term. -

- -

-To search for terms with spaces you have to put them in quotes. -

- -

-Usage: -

+
+

Using the ck actions

+
-
# search for parenthesis
-$ ck search \(
-# search term with spaces
-$ ck grep "This is a space"
-# both
-$ ck s "(add 2 4)"
-# and a normal one
-$ ck -s alias
-
-
- -

-If you want to use more advanced grep techniques or even -a different pattern matching program you can do it like so: -

- -
-
# with xargs
-$ ck ls paths | xargs grep -E 'A|B'
-# or in bash
-$ for i in $(ck ls paths); do grep -E 'A|B' $i; done
-# or in zsh
-$ for i ($(ck ls paths)) grep -E 'A|B' $i
-
-
-
-
- -
-

edit

-
-

-or e or -e -

- -

-Edit configurations with $EDITOR. -

- -

-Edit takes at least one and up to two arguments. -

+
# list the configs in a treelike structure with basename only
+$ ck list tree -b
+# or with the full path & attributes
+$ ck list tree -a
 
-

-The first argument is the programName. If the program has a primary configuration -edit will open this. If the program has only one configuration edit will open it. -If the program has more than 1 configurations and no primary, it will print the -avaliable configurations and exit. -

+# list only the paths in python or lisp like lists +$ ck list paths -t lisp +$ ck list programs -t python -b -a -

-The second argument is the configName. If it exists it will open, else it will -print the avaliable configurations and exit. -

+# list emacs configs +$ ck list -p emacs -

-Usage: -

-
-
# suppose this is our ck instance
-$ ck list tree -a
-emacs:
-|- init.el
-|- accounts.el [s]
-|- orgconf.org [p]
+# search the configs
+$ ck search Hostname
+$ ck search "search term with spaces"
+# escape symbols
+$ ck search \(
 
-# edit the primary emacs config
+# edit the primary config of emacs
 $ ck edit emacs
-
-# edit a specific emacs config, other than the primary
-$ ck edit emacs accounts.el
+# edit a non-primary config of ssh
+$ ck e ssh authorized_keys
+# edit a root config
+$ sudo ck -c /home/ckuser e ssh sshd_config
+
+# delete a program with all the configs
+$ ck delete emacs
+# or a specific config
+$ ck del -c /home/ckuser/.emacs.d/init.el
+
+# restore all links (on a new instalation)
+$ ck restore all
+# restore a program's links
+$ ck r -p emacs
+
+# get help for an action
+$ ck h add
+$ ck --help e
 
- -
-

restore

-
-

-or r or -r -

- -

-Restore links. -

- -

-Given a working ck instance (ckdb + ckrc + directories in ckrc with configs) -restore shall recreate the links from the config directories in ckrc -back to their corresponding position when added in ck. -

- -

-It is useful for copying your configs to a new linux installation -or restoring deleted links. -

- -

-It can either restore a specific program or all of them: -

-
-
# restore progName
-ck restore -p progName
-# restore all
-ck r all
-
-

-Note: -If ck tracks configs that are owned by root, simply running -`ck restore …` will fail due to permissions. To remedy this, ck will alter the -owner and group of a link to match the one in the ckrc directories. -Thus, running `sudo ck -c home/myuser.ck restore ..` will restore -the root user's links as it should and the user links will have -the user as the owner instead of the root. -

- -

-ck checks that the configs exist and that the location for the link -is avaliable before making any links. However, in the even that symlink -fails for some other reason, the process will stop as is. Make sure you -take care of the already created links, if that's the case. -

-
-
-
-
-
-

manpage

-
+
+

manpage

+
- + @@ -933,6 +650,7 @@ take care of the already created links, if that's the case. NAME
SYNOPSIS
DESCRIPTION
+CONFIGURATION
OPTIONS
ACTIONS
EXIT STATUS
@@ -968,11 +686,12 @@ ck add PROGRAM_NAME CONFIG_PATH [−p] ck delete PROGRAM_NAME|{−c CONFIG_PATH}
-ck list tree 
[−a]
+ck list tree 
[−a] [−b] +
ck list
{-p PROGRAM_NAME}|programs|paths [−t {plain|python|lisp}] [−a] -
+[−b]
ck list ckconf
ck edit
PROGRAM_NAME [CONFIG_BASENAME]
@@ -1015,6 +734,26 @@ you can sync the VERSION_CONRTOL_DIR and given these two directories and the correspondig rc file and database.

+

CONFIGURATION + +

+ + +

ck uses +sqlite to index the configuration files. The init +action by default creates a directory named .ck +under $HOME in witch the ckrc and ckdb +files reside. See the FILES section for more +details.

+ +

One can have +multiple config directories with different +configurations each. Using the +config or −c option one can +set the path in which ck will search for ckrc and +ckdb. See the OPTIONS section for more +details.

+

OPTIONS

@@ -1204,11 +943,11 @@ List programs, configs and ck configuration values.

USAGE

ck list -tree [−a]
+tree 
[−a] [−b]
ck list
{-p PROGRAM_NAME}|programs|paths [−t {plain|python|lisp}] [−a] -
+[−b]
ck list ckconf

@@ -1269,6 +1008,12 @@ or lisp to print it like a lisp list.

[root] if the file is owned by the root user.

+

−b

+ +

Print the config +basename instead of the full path.

+ +

EXAMPLES

$ ck list tree -a
@@ -1374,6 +1119,32 @@ installation or restoring deleted links. It can either restore a specific program or all of them.

+

NOTE: If +ck tracks configs that are owned by root, +simply running

+ +

$ ck restore ...

+ +

will fail due to permissions. +To remedy this, ck will alter the +owner and group of a link to match +the one in the original config file. Thus, +running

+ +

$ sudo ck -c /home/ckuser/.ck +restore ...

+ +

will restore the root +user’s links as it should and the user links will have +the user as the owner instead of the root.

+ +

ck +checks that the configs exist and that the location +for the link is avaliable before making any links. However, +in the even that symlink 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.

+

USAGE

@@ -1514,7 +1285,7 @@ flags
: @CMAKE_C_FLAGS@

-

Created: 2018-10-28 Sun 13:22

+

Created: 2018-10-29 Mon 17:20

Validate

-- cgit v1.2.3