aboutsummaryrefslogtreecommitdiffstats
path: root/ck.1
blob: d120757e0de6c0e31778a75187278b4fc8e2943d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
.TH ck 1 "2018-10-27" Linux "ck - the config keeper"
.SH NAME
ck \- manage configuration across the system
.SH SYNOPSIS
.SY ck
.OP \-v\fR|\fB\-\-verbose
.OP \-c\fR|\fB\-\-config DIR
.IR action \ [.\|.\|.]
.YS
.ns
.SY ck
.OP version\fR|\fB\-\-version
.YS
\" Init
.SY ck
.B init
.I VERSION_CONTROL_DIR SECRET_DIR
.YS
\" Add
.SY ck
.B add
.I PROGRAM_NAME CONFIG_PATH
.OP \-p
.OP \-s
.YS
\" Delete
.SY ck
.B delete
.I PROGRAM_NAME
.RI [ CONFIG_BASENAME ]
.YS
\" List
.SY ck
.B list tree
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list
.BI \-p \ PROGRAM_NAME
.OP \-t list-type
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list
.B programs
.OP \-t list-type
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list
.B paths
.OP \-t list-type
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list ckconf
.YS
\" Edit
.SY ck
.B edit
.I PROGRAM_NAME
.RI [ CONFIG_BASENAME ]
.YS
\" Search
.SY ck
.B search
.I SEARCH_TERM
.YS
\" Restore
.SY ck
.B restore \-p
.I PROGRAM_NAME
.YS
.ns
.SY ck
.B restore all
.YS
\" Help
.SY ck
.BI help \ action
.YS
.SH DESCRIPTION
.B ck
manages configuration files in a Linux system. To that end it provides an
.B action
based command line interface.
.P
.B ck
needs a database and an rc file to run. It also needs two
directories (stored in the rc file), the
.I VERSION_CONRTOL_DIR
and the
.IR SECRET_DIR .
This is where the configurations will end up after they are added to
.BR ck .
The
.B init
action takes care of them. For more details see the
.BR ACTIONS \ and \ FILES
sections below.
.P
In
.B ck
terms a
.I program
is an entity that has one or more
.I configs
attached to it. Each
.I program
can have exactly one
.BI primary \ config \fR.
Upon adding a
.I config
to
.BR ck ,
it is moved to the appropriate directory, and then symbolically linked
back to it's original place (\fIln -s\fR).
.P
In a later time you can sync the
.I VERSION_CONRTOL_DIR
and
.IR SECRET_DIR .
You can also
.B restore
the links given these two directories and the correspondig rc file and database.
.SH CONFIGURATION
.B ck
uses
.B sqlite
to index the configuration files. The
.B init action
by default creates a directory named
.I .ck
under
.I $HOME
in witch the
.I ckrc
and
.I ckdb
files reside. See the
.B FILES
section for more details.
.P
One can have multiple
.B config directories
with different configurations each.
Using the
.BR config \ or \ \-c
option one can set the path
in which ck will search for
.I ckrc
and
.IR ckdb .
See the
.B OPTIONS
section for more details.
.P
.SH OPTIONS
Change
.B ck
behaviour using the following options. They must be present before any
.B action.
.TP
.B \-\-verbose\fR, \fB\-v
[WIP]
.br
Currently prints the log. Must be the first argument in order to work.
.TP
.B \-\-config \fIDIR\fR, \fB\-c \fIDIR
Use
.BR ckdb \ and \ ckrc
residing in
.I DIR
instead of the default
.IR ~/.ck/ .
.TP
.B \-\-version\fR, \fBversion
Print version and licence information, and quit.
.SH ACTIONS
Each
.B action
has several aliases. The selected
.B action
must be after the
.B OPTIONS
if any. All available
.B actions
can be seen in the
.B SYNOPSIS
section above.
.P
Each
.B action
takes a number of arguments and flags.
.SS "INITIALIZE"
Create the
.B ck
database
.RI ( ckdb )
and initialize it. Create the ck config file
.RI ( ckrc )
and add the directory paths to it.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B init
.I VERSION_CONTROL_DIR SECRET_DIR
.YS
.RE
.TP 2
.B ALIASES
.BR init , \ i , \ \-i
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I VERSION_CONTROL_DIR
The directory where
.B configs
will be stored by default.
.B File must exist\fR.
.TP 21
.I SECRET_DIR
The directory where
.B configs
will be stored when using the
.B \-s
flag in
.B add\fR. \fBFile must exist\fR.
.RE
.TP 2
.B EXAMPLES
.EX
$ ck init /home/ckuser/configs/vc home/ckuser/configs/sec
$ ck i configs/vc configs/sec
.EE
.SS "ADD CONFIG"
Add a
.B config
to the database
.RI ( ckdb )\fR.
Each
.B config
belongs to a
.BR program .
Every \fBprogram\fR can have
multiple
.B configs
under it and one of them can be
.BR primary .
The
.B edit action
will open the
.B primary config
by default.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B add
.I PROGRAM_NAME CONFIG_PATH
.OP \-p
.OP \-s
.YS
.RE
.TP 2
.B ALIASES
.BR add , \ a , \ \-a
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I PROGRAM_NAME
The name of the
.B program
the
.B config
belongs at.
.TP 21
.I CONFIG_PATH
Path to the
.BR config .
Can be relative.
.RE
.TP 2
.B FLAGS
.ns
.RS 2
.TP 21
.B \-s
Mark the
.B config
as secret. It will be stored
on the
.IR SECRET_DIR .
.TP 21
.B \-p
Mark the
.B config
as primary. The
.B edit action
will open this by default.
.RE
.TP 2
.B EXAMPLES
.EX
# 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
.EE
.SS "DELETE CONFIG"
Delete a
.B config
or a
.B program
from the database
.RI ( ckdb )\fR.
This will not touch the actual file and link. It is up to the user
to handle it.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B delete
.I PROGRAM_NAME
.RI [ CONFIG_BASENAME ]
.YS
.RE
.TP 2
.B ALIASES
.BR delete , \ del , \ d , \ \-d
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I PROGRAM_NAME
Delete the
.B program
and all it's
.BR configs .
.TP 21
.I CONFIG_BASENAME
The basename of the
.B config
file to be deleted. It has to follow the
.IR PROGRAM_NAME .
.RE
.TP 2
.B EXAMPLES
.EX
$ ck delete emacs
$ ck del emacs init.el
.EE
.SS "LIST VALUES"
List programs, configs and ck configuration values.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B list tree
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list
.BI \-p \ PROGRAM_NAME
.OP \-t list-type
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list
.B programs
.OP \-t list-type
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list
.B paths
.OP \-t list-type
.OP \-a
.OP \-b
.YS
.ns
.SY ck
.B list ckconf
.YS
.RE
.TP 2
.B ALIASES
.BR list , \ ls , \ l , \ -ls , \ \-l
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.B tree
List
.B programs
with their
.B configs
in a tree like structure.
.TP 21
.B paths
List all the
.B config
paths
.B ck
keeps track of.
.TP 21
.B programs
List all the
.B programs ck
keeps track of.
.TP 21
.BI \-c \ PROGRAM_NAME
List all the
.B configs
of
.IR PROGRAM_NAME .
.TP 21
.BI ckconf
List the
.B ck
configuration values, like the
.IR VERSION_CONTROL_DIR \ and \ SECRET_DIR .
.RE
.TP 2
.B FLAGS
.ns
.RS 2
.TP 21
.BI \-t \ type
Set the type of the
.BR list .
Can be either
.B plain
(the default) a simple list,
.B python
to print it like a python array or
.B lisp
to print it like a lisp list.
.TP 21
.B \-a
Show attributes to the listing (when aplicable).
These are
.B [s]
for
.BR secret ,
.B [p]
for
.B primary
and
.B [root]
if the file is owned by the root user.
.TP 21
.B \-b
Print the
.B config
basename instead of the full path.
.RE
.TP 2
.B EXAMPLES
.EX
$ ck list tree -a
$ ck list paths -t lisp
$ ck list programs -t python
$ ck list -p emacs
.EE
.SS "EDIT CONFIGS"
Edit a
.B config
stored in
.B ck
with the
.IR $EDITOR .
.B Edit
will open the
.B primary config
of the
.BR program .
If there is no
.B primary config
but the
.B program
only has one
.BR config ,
.B edit
will open that.
Whenever there is ambiguity, a list
of possible
.B configs
will be shown.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B edit
.I PROGRAM_NAME
.RI [ CONFIG_BASENAME ]
.YS
.RE
.TP 2
.B ALIASES
.BR edit , \ e , \ \-e
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I PROGRAM_NAME
The name of the
.B program
to be edited. If the
.B program
has only one
.B config
or you want to edit the
.B primary
one, no further action is required.
.TP 21
.I CONFIG_BASENAME
The basename of the
.B config
to be edited. This has to follow the
.I PROGRAM_NAME
name. It is only needed when editing a
.B config
other than the
.B primary
one.
.RE
.TP 2
.B EXAMPLES
.EX
$ ck edit emacs
$ ck e tmux .tmux.conf
.EE
.SS "SEARCH CONFIGS"
Grep through the configs. This
.B action
is equivalent to this:
.br
.RS 2
$ ck ls paths | xargs grep -H -n "search term"
.RE
.br
Thus for more advanced search through the
.B configs
one can use other programs and replace grep in the command above.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B search
.I SEARCH_TERM
.YS
.RE
.TP 2
.B ALIASES
.BR search , \ grep , \ s , \ \-s
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I 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).
.RE
.TP 2
.B EXAMPLES
.EX
$ ck search "search term"
$ ck search "\\(require"
.EE
.SS "RESTORE CONFIGS"
Given a working
.B ck
instance (\fIckdb \fR+ \fIckrc\fR + directories in \fIckrc\fR with
.BR configs ), \ restore
shall recreate the links from the
.B config
directories in
.I ckrc
back to their corresponding position when added to
.BR ck .
It is useful for copying
.B configs
to a new linux installation or
.B restoring
deleted links. It can either
.B restore
a specific
.B program
or all of them.
.P
.BR NOTE :
If
.B ck
tracks
.B configs
that are owned by root, simply running
.br
.RS 2
$ ck restore \.\.\.
.RE
.br
will fail due to permissions. To remedy this,
.B ck
will alter the
.BR owner \ and \ group
of a link to match the one in the original
.B config
file.
Thus, running
.RS 2
$ sudo ck -c /home/ckuser/.ck restore \.\.\.
.RE
will
.B restore
the root user's links as it should and the user links will have
the user as the owner instead of the root.
.P
.B ck
checks that the
.B configs
exist and that the location for the link
is avaliable before making any links. However, in the even that
.B 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.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.B restore \-p
.I PROGRAM_NAME
.YS
.ns
.SY ck
.B restore all
.YS
.RE
.TP 2
.B ALIASES
.BR restore , \ r , \ \-r
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I PROGRAM_NAME
The name of the
.B program
to be restored.
.TP 21
.B all
Restore all
.B programs ck
keeps track of.
.RE
.TP 2
.B EXAMPLES
.EX
$ ck restore all
$ ck restore -p emacs
.EE
.SS "GET HELP"
Get help for any given
.B action
from the command line.
.TP 2
.B USAGE
.ns
.RS 2
.SY ck
.BI help \ action
.YS
.RE
.TP 2
.B ALIASES
.BR help , \ h , \ \-\-help , \ -h , \ \-?
.TP 2
.B ARGUMENTS
.ns
.RS 2
.TP 21
.I action
Any
.B action alias
you wish to get help for.
.RE
.TP 2
.B EXAMPLES
.EX
$ ck help add
$ ck h d
$ ck --help ls
.EE
.SH EXIT STATUS
.B ck
shall return 0 if the action was completed without an error, -1 otherwise
.SH FILES
By default
.B ck
will store it's files in
.IR ~/.ck/ .
Using the
.BR \-c | \-\-config
one can change this.
.SS "ck generated files"
.TP
.I ~/.ck/ckrc
Store the configuration values (\fIVERSION_CONTROL_DIR\fR and \fISECRET_DIR\fR).
.TP
.I ~/.ck/ckdb
SQLite3 database.
.SS "User files"
.TP
.I VERSION_CONTROL_DIR
This is where the configuration files will end up by default. It's value is set with the
.B init
action, but can be changed by editing
.IR ckrc .
.TP
.I SECRET_DIR
This is where the configuration files will end up when adding them with the
.B -s
flag. It's value is set with the
.B init
action, but can be changed by editing
.IR ckrc .
.SH BUILD VALUES
.BR compiler :
@CMAKE_C_COMPILER@
.br
.BR flags :
@CMAKE_C_FLAGS@
.SH VERSION
ck version @ck_MAJOR_VERSION@.@ck_MINOR_VERSION@.@ck_PATCH_VERSION@
.SH AUTHOR
gramanas