From 56fdf6de6ee00f1eb4303065c26811310a7c0728 Mon Sep 17 00:00:00 2001 From: gramanas Date: Sun, 28 Oct 2018 13:23:56 +0200 Subject: Add manpage to readme --- README.html | 772 ++++++++++++++++++++++++++++++++++++++++++++++++++++------- README.org | 4 + src/ckutil.c | 14 -- src/ckutil.h | 2 - 4 files changed, 694 insertions(+), 98 deletions(-) diff --git a/README.html b/README.html index d22b910..f6bd550 100644 --- a/README.html +++ b/README.html @@ -3,7 +3,7 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - + @@ -232,52 +232,53 @@ for the JavaScript code in this tag.

Table of Contents

-
-

ck

-
+
+

ck

+

The Config Keeper

@@ -333,9 +334,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). @@ -348,9 +349,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. @@ -368,13 +369,13 @@ You can also read the manual down below.

-
-

build it

+
+

build it

-
-

requirements

-
+
+

requirements

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

make && install

-
+
+

make && install

+

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

@@ -408,16 +409,16 @@ 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:

@@ -438,9 +439,9 @@ To use any one of them append it after the cmake command like so:
-
-

compiler

-
+
+

compiler

+

Pick your favorite

@@ -470,9 +471,9 @@ Pick your favorite
-
-

tests

-
+
+

tests

+

The testing "suite" is a bash script that runs regression and unit tests. Regression tests are under the tests/ directory @@ -481,9 +482,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: @@ -495,9 +496,9 @@ go to the build directory and type:

-
-

test suite

-
+
+

test suite

+
$ ./test-ck -h
 ck test suite
@@ -515,8 +516,8 @@ flags:
 
-
-

manual

+
+

manual

ck's goal is to assist with the configuration file management. @@ -568,9 +569,9 @@ of flags one has to pass to ck.

-
-

ck configuration

-
+
+

ck configuration

+

ck uses sqlite to index the configuration files. The init action creates a .ck directory (under $HOME) @@ -608,13 +609,13 @@ $ ck -c /someplace/else ...

-
-

Actions

-
+
+

Actions

+
-
-

init

-
+
+

init

+

or i or -i

@@ -644,9 +645,9 @@ $ ck init /path_to/where_you_want/your_configs/to_be -

add

-
+
+

add

+

or a or -a

@@ -687,9 +688,9 @@ $ ck add program_name config_path [-s] [-p]
-
-

list

-
+
+

list

+

or ls or l or -l

@@ -752,9 +753,9 @@ $ ck -l ckconf
-
-

search

-
+
+

search

+

or grep or s or -s

@@ -803,9 +804,9 @@ $ for i ($(ck ls paths)) grep -E 'A|B' $
-
-

edit

-
+
+

edit

+

or e or -e

@@ -851,9 +852,9 @@ $ ck edit emacs accounts.el
-
-

restore

-
+
+

restore

+

or r or -r

@@ -904,9 +905,616 @@ take care of the already created links, if that's the case.
+
+

manpage

+
+ + + + + + + + + +ck + + + + +

ck

+ +NAME
+SYNOPSIS
+DESCRIPTION
+OPTIONS
+ACTIONS
+EXIT STATUS
+FILES
+BUILD VALUES
+VERSION
+AUTHOR
+ +
+ + +

NAME + +

+ + +

ck − +manage configuration across the system

+ +

SYNOPSIS + +

+ + +

ck +[−v|−−verbose] +[−c|−−config DIR] +action [...]
+ck
[version|−−version]
+ck init
VERSION_CONTROL_DIR SECRET_DIR
+ck add
PROGRAM_NAME CONFIG_PATH [−p] +[−s]
+ck delete
+PROGRAM_NAME|{−c CONFIG_PATH} +
+ck list tree 
[−a]
+ck list
+{-p PROGRAM_NAME}|programs|paths [−t +{plain|python|lisp}] [−a] +
+ck list ckconf
+ck edit
+PROGRAM_NAME [CONFIG_BASENAME]
+ck search
SEARCH_TERM
+ck restore
PROGRAM_NAME|all
+ck help
action

+ +

DESCRIPTION + +

+ + + +

ck +manages configuration files in a Linux system. To that end +it provides an action based command line +interface.

+ +

ck needs +a database and an rc file to run. It also needs two +directories (stored in the rc file), the +VERSION_CONRTOL_DIR and the SECRET_DIR. This +is where the configurations will end up after they are added +to ck. The init action takes care of them. For +more details see the +ACTIONS and FILES sections +below.

+ +

In ck +terms a program is an entity that has one or more +configs attached to it. Each program can have +exactly one primary config. Upon adding a +config to ck, it is moved to the appropriate +directory, and then symbolically linked back to it’s +original place (ln -s).

+ +

In a later time +you can sync the VERSION_CONRTOL_DIR and +SECRET_DIR. You can also restore the links +given these two directories and the correspondig rc file and +database.

+ +

OPTIONS + +

+ + +

Change +ck behaviour using the following options. They must +be present before any action.
+−−verbose
, −v

+ +

[WIP]
+Currently prints the log. Must be the first argument in +order to work.

+ +

−−config +DIR, −c DIR

+ +

Use +ckdb and ckrc residing in DIR +instead of the default ~/.ck/.

+ +

−−version, +version

+ +

Print version and licence +information, and quit.

+ +

ACTIONS + +

+ + +

Each +action has several aliases. The selected +action must be after the OPTIONS if any. All +available actions can be seen in the SYNOPSIS +section above.

+ +

Each +action takes a number of arguments and flags.

+ +

Initialize +ck
+Create the ck database (ckdb) and initialize +it. Create the ck config file (ckrc) and add the +directory paths to it.

+ + +

USAGE

+ +

ck init +VERSION_CONTROL_DIR SECRET_DIR

+ + +

ALIASES

+ + +

initi−i

+ + +

ARGUMENTS

+ +

VERSION_CONTROL_DIR

+ +

The directory where +configs will be stored by default. File must +exist.

+ + +

SECRET_DIR

+ +

The directory where +configs will be stored when using the −s +flag in add. File must exist.

+ + +

EXAMPLES

+ +

$ ck init +/home/ckuser/configs/vc home/ckuser/configs/sec
+$ ck i configs/vc configs/sec

+ +

Add +config
+Add a config to the database (ckdb). Each +config belongs to a program. Every +program can have multiple configs under it and +one of them can be primary. The edit action +will open the primary config by default.

+ + +

USAGE

+ +

ck add PROGRAM_NAME +CONFIG_PATH [−p] [−s]

+ + +

ALIASES

+ + +

adda−a

+ + +

ARGUMENTS

+ +

PROGRAM_NAME

+ +

The name of the program +the config belongs at.

+ + +

CONFIG_PATH

+ +

Path to the config. Can +be relative.

+ + +

FLAGS

+ +

−s

+ +

Mark the config as +secret. It will be stored on the SECRET_DIR.

+ + +

−p

+ +

Mark the config as +primary. The edit action will open this by +default.

+ + +

EXAMPLES

+ +

# 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

+ +

Delete +config
+Delete a config or a program from the database +(ckdb). This will not touch the actual file and link. +It is up to the user to handle it.

+ + +

USAGE

+ +

ck delete +PROGRAM_NAME|{−c CONFIG_PATH}

+ + +

ALIASES

+ + +

deletedeld−d

+ + +

ARGUMENTS

+ +

PROGRAM_NAME

+ +

Delete the program and +all it’s configs.

+ + +

−c CONFIG_PATH

+ +

Delete the config. This +has to be the full path of the link as shown by the list +action.

+ + +

EXAMPLES +
+$ ck delete emacs
+$ ck del -c /home/ckuser/.emacs.d/init.el

+ +

List +
+List programs, configs and ck configuration values.

+ + +

USAGE

+ +

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

+ + +

ALIASES

+ + +

listlsl-ls−l

+ + +

ARGUMENTS

+ +

tree

+ +

List programs with their +configs in a tree like structure.

+ + +

paths

+ +

List all the config +paths ck keeps track of.

+ + +

programs

+ +

List all the programs ck +keeps track of.

+ + +

−c PROGRAM_NAME

+ +

List all the configs of +PROGRAM_NAME.

+ + +

ckconf

+ +

List the ck +configuration values, like the +VERSION_CONTROL_DIR and SECRET_DIR.

+ + +

FLAGS

+ +

−t

+ +

Set the type of the +list. Can be either plain (the default) a +simple list, python to print it like a python array +or lisp to print it like a lisp list.

+ + +

−a

+ +

Add attributes to the listing +(when aplicable). The attributes are [s] for +secret, [p] for primary and +[root] if the file is owned by the root user.

+ + +

EXAMPLES

+ +

$ ck list tree -a
+$ ck list paths -t lisp
+$ ck list programs -t python
+$ ck list -p emacs

+ +

Edit +configs
+Edit a config stored in ck with the +$EDITOR. Edit will open the primary +config of the program. If there is no primary +config but the program only has one +config, edit will open that. Whenever there is +ambiguity, a list of possible configs will be +shown.

+ + +

USAGE

+ +

ck edit +PROGRAM_NAME [CONFIG_BASENAME]

+ + +

ALIASES

+ + +

edite−e

+ + +

ARGUMENTS

+ +

PROGRAM_NAME

+ +

The name of the program +to be edited. If the program has only one +config or you want to edit the primary one, no +further action is required.

+ + +

CONFIG_BASENAME

+ +

The basename of the +config to be edited. This has to follow the +program name. It is only needed when editing a +config other than the primary one.

+ + +

EXAMPLES

+ +

$ ck edit emacs
+$ ck e tmux .tmux.conf

+ +

Search +configs
+Grep through the configs. This action is equivalent +to this:

+ +

$ ck ls paths | +xargs grep -H -n "search term"

+ +

Thus for more +advanced search through the configs one can use other +programs and replace grep in the command above.

+ + +

USAGE

+ +

ck search +SEARCH_TERM

+ + +

ALIASES

+ + +

searchgreps−s

+ + +

ARGUMENTS

+ +

SEARCH_TERM

+ +

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).

+ + +

EXAMPLES

+ +

$ ck search "search +term" $ ck search "quire"

+ +

Restore +configs
+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 to ck. It +is useful for copying configs to a new linux +installation or restoring deleted links. It can +either restore a specific program or all of +them.

+ + +

USAGE

+ +

ck restore +PROGRAM_NAME|all

+ + +

ALIASES

+ + +

restorer−r

+ + +

ARGUMENTS

+ +

PROGRAM_NAME

+ +

The name of the program +to be restored.

+ +

all

+ +

Restore all programs ck +keeps track of.

+ + +

EXAMPLES

+ +

$ ck restore all
+$ ck restore -p emacs

+ +

Get help +
+Get help for any given action from the command +line.

+ + +

USAGE

+ +

ck help +action

+ + +

ALIASES

+ + +

helph−−help-h−?

+ + +

ARGUMENTS

+ +

action

+ +

Any action alias you +wish to get help for.

+ + +

EXAMPLES

+ +

$ ck help add
+$ ck h d
+$ ck --help ls

+ +

EXIT STATUS + +

+ + +

ck shall +return 0 if the action was completed without an error, -1 +otherwise

+ +

FILES + +

+ + +

By default +ck will store it’s files in ~/.ck/. +Using the −c|−−config one +can change this.

+ +

ck generated +files
+~/.ck/ckrc

+ +

Store the configuration values +(VERSION_CONTROL_DIR and SECRET_DIR).

+ +

~/.ck/ckdb

+ +

SQLite3 database.

+ +

User +files
+VERSION_CONTROL_DIR

+ +

This is where the configuration +files will end up by default. It’s value is set with +the init action, but can be changed by editing +ckrc.

+ +

SECRET_DIR

+ +

This is where the configuration +files will end up when adding them with the -s flag. +It’s value is set with the init action, but can +be changed by editing ckrc.

+ +

BUILD VALUES + +

+ + + +

compiler: +@CMAKE_C_COMPILER@
+flags
: @CMAKE_C_FLAGS@

+ +

VERSION + +

+ + +

ck version +@ck_MAJOR_VERSION@.@ck_MINOR_VERSION@.@ck_PATCH_VERSION@

+ +

AUTHOR + +

+ + +

gramanas

+
+ + +
+
-

Created: 2018-10-27 Sat 12:38

+

Created: 2018-10-28 Sun 13:22

Validate

diff --git a/README.org b/README.org index 3e1c20f..379e61c 100644 --- a/README.org +++ b/README.org @@ -387,3 +387,7 @@ 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 +#+BEGIN_SRC sh :results output html :exports results + groff ck.1 -mandoc -Thtml +#+END_SRC diff --git a/src/ckutil.c b/src/ckutil.c index 06d12da..79d7fd3 100644 --- a/src/ckutil.c +++ b/src/ckutil.c @@ -34,20 +34,6 @@ int util_is_dir(const char *path) { return 1; } -void util_replace_slash_with_uscore(char *s) { - if (!s) { - return; - } - int i = 0; - while (*s != '\0') { - if (*s == '/' && i != 0) { - *s = '_'; - } - s++; - i++; - } -} - int util_file_exists(const char* path, char *absPath) { if (!path || !absPath) { return 0; diff --git a/src/ckutil.h b/src/ckutil.h index 9f3cb39..8ca9ca1 100644 --- a/src/ckutil.h +++ b/src/ckutil.h @@ -78,8 +78,6 @@ extern int util_is_file_rw(const char *path); /* Returns 1 if file is link 0 otherwise */ extern int util_is_file_link(const char *path); -extern void util_replace_slash_with_uscore(char *s); - /* Wrapper around mkdir with 0775 permissions */ extern void util_mkdir(const char *path); -- cgit v1.2.3