diff options
Diffstat (limited to 'src/actionhelper.c')
-rw-r--r-- | src/actionhelper.c | 102 |
1 files changed, 92 insertions, 10 deletions
diff --git a/src/actionhelper.c b/src/actionhelper.c index 14e8782..6507e7b 100644 --- a/src/actionhelper.c +++ b/src/actionhelper.c @@ -100,10 +100,6 @@ DelOpt del_make_options(cklist *args) { return delOpt; } delOpt.arg = list_get(args); - if (!util_is_file_rw(delOpt.arg)) { - delOpt.err = DEL_ERR_WRONG_PATH; - return delOpt; - } } else { delOpt.arg = list_get(args); } @@ -198,7 +194,7 @@ int init_create_config_file(UserOpt *opt) { ListOpt list_make_options(cklist *args) { list_rewind(args); ListOpt listOpt = { - ._lt = LT_NONE, + ._lt = LT_TREE, ._lst = LST_PLAIN, .pName = NULL, .attr = 0, @@ -280,10 +276,10 @@ void print_ADD_result(int err) { void print_DEL_result(int err) { if (!err) { - HELP("ckdb updated succesfully"); + HELP("ckdb updated succesfully."); return; } - ERR("Could not complete delete transaction"); + ERR("Could not complete delete transaction."); } void print_EDIT_result(int err) { @@ -311,8 +307,94 @@ void print_SEARCH_result(int err) { void print_HELP_result(int err) { if (!err) { - printf("succes\n"); - return; } - printf("failure\n"); +} + +void print_INIT_help() { + ckhelp("Initialize the database and create the file that holds"); + ckhelp("the paths where configurations will be stored."); + ckhelp("Namely the version control and the secret directories.\n"); + ckhelp("It takes two arguments:"); + ckhelp(" `version_control_dir`: the path to the version control directory"); + ckhelp(" `secret_dir`: the path to the secret directory"); + report_help(); +} + +void print_ADD_help() { + ckhelp("Add a config for ck to keep track of.\n"); + ckhelp("The file will be stored to the desired directory and will"); + ckhelp("be linked back to it's original position.\n"); + ckhelp("It takes the following arguments:"); + ckhelp(" `program_name`: the name of the config's program"); + ckhelp(" `path`: path to the configuration (can be relative)\n"); + ckhelp("It also takes the flags:"); + ckhelp(" `-p`: to mark a configuration as primary (so it will open with edit by default)"); + ckhelp(" `-s`: to mark a configuration as secret (to end up in the secret dir)\n"); + ckhelp("Note:\nThere can be only one primary config per program."); + ckhelp("It is advised to use your distribution's package name for the program_name."); + ckhelp("The arguments have to be in the order shown here (name -> path -> flags)"); + report_help(); +} + +void print_DEL_help() { + ckhelp("Delete a program/config from ck.\n"); + ckhelp("This will not interfere with any files or links, it will"); + ckhelp("just remove the program/config from the ck database.\n"); + ckhelp("To completely remove a program/config you have to manually"); + ckhelp("erase it from the folder it is stored. You can do it either before"); + ckhelp("or after running this command.\n"); + ckhelp("It takes one or two arguments:"); + ckhelp(" `program_name`: will delete all configs under that program."); + ckhelp(" `-c path`: will delete the config specified by the path.\n"); + ckhelp("Note:\nThe path that follows the -c option has to be the path shown"); + ckhelp("when you list the configurations of a program. (ck help list for more)"); + report_help(); +} + +void print_EDIT_help() { + ckhelp("Edit a config tracked by ck.\n"); + ckhelp("It takes one or two arguments:"); + ckhelp(" `program_name`: will open the primary config of that program (if set)"); + ckhelp(" `config_name`: will open the specified config\n"); + ckhelp("Note:\nIf a program has only one config, edit will open it even if it's not the primary."); + ckhelp("Edit will use the $EDITOR and if it's not set it falls back to nano."); + ckhelp("If there is ambiguity ck will list the available config names"); + ckhelp("for the program specified."); + report_help(); +} + +void print_LIST_help() { + ckhelp("List various stuff ck knows about.\n"); + ckhelp("List can work in a few different ways:"); + ckhelp(" `tree`: list all the programs and paths in a tree like structure."); + ckhelp(" `paths`: list all the configs ck keeps track."); + ckhelp(" `programs`: list all the programs ck keeps track."); + ckhelp(" `-p program_name`: list only the configs of the specified program."); + ckhelp(" `ckconf`: list the ck configuration values.\n"); + ckhelp("There are also some flags:"); + ckhelp(" `-a`: add the attributes next to the config paths (secret,primary)"); + ckhelp(" `-t`: change the list type. (does not work with tree or ckconf)"); + ckhelp(" `plain`: default plain listing"); + ckhelp(" `python`: enclose the list in [ , ]"); + ckhelp(" `lisp`: enclose the list in ( , )"); + report_help(); +} + +void print_SEARCH_help() { + ckhelp("Search through the configs ck keeps track of.\n"); + ckhelp("Search performs a grep with the supplied term to each"); + ckhelp("file ck keeps track and prints the results.\n"); + ckhelp("The exact grep command used is `grep -H -n`\n"); + ckhelp("It takes one argument:"); + ckhelp(" `search_term`\n"); + ckhelp("Note:\nIf you want to search for a phrase enclose it in \'\' or \"\""); + report_help(); +} + +void print_HELP_help() { + ckhelp("Get help for ck actions.\n"); + ckhelp("It takes one argument:"); + ckhelp(" `action`\n"); + ckhelp("Note:\nRunning ck without arguments will print all the available actions."); + report_help(); } |