Projects acosom ziit ziit-cli Commits 28fe8f3a
ctrl k
  • src/add.c
    ■ ■ ■ ■
    skipped 34 lines
    35 35   
    36 36  static void print_help()
    37 37  {
    38  - printf("Usage: ziit add [OPTION...] <interval> <message> [<tags>]\n");
     38 + printf("Usage: ziit add [OPTION...] <interval>\n");
    39 39   printf("Adds a new entry to the time log.\n\n");
    40 40   cag_option_print(options, CAG_ARRAY_SIZE(options), stdout);
    41 41  }
    skipped 107 lines
  • src/init.c
    ■ ■ ■ ■ ■ ■
    skipped 124 lines
    125 125   usersk = strdup(cag_option_get_value(&ctx));
    126 126   break;
    127 127   case 'h':
     128 + printf("Usage: ziit init [OPTION...]\n");
     129 + printf("Initializes the repository configuration.\n\n");
    128 130   cag_option_print(options, CAG_ARRAY_SIZE(options), stdout);
    129 131   return EXIT_SUCCESS;
    130 132   }
    skipped 55 lines
  • src/main.c
    ■ ■ ■ ■ ■ ■
    skipped 1 lines
    2 2  #include <strings.h>
    3 3   
    4 4  #include "add.h"
    5  -#include "constants.h"
    6 5  #include "config.h"
     6 +#include "constants.h"
    7 7  #include "init.h"
    8 8  #include "list.h"
    9  -#include "summary.h"
    10 9  #include "remove.h"
    11 10  #include "status.h"
     11 +#include "summary.h"
    12 12  #include <cargs.h>
    13 13  #include <confuse.h>
    14 14  #include <stdlib.h>
    15 15  #include <string.h>
    16 16  #include <syslog.h>
    17 17   
     18 +static cag_option options[] = {
     19 + {.identifier = 'v',
     20 + .access_letters = "v",
     21 + .access_name = "version",
     22 + .description = "Outputs the version of the ziit client.",
     23 + .value_name = NULL},
     24 + {.identifier = 'h',
     25 + .access_letters = "h",
     26 + .access_name = "help",
     27 + .description = "Shows the help for the add command.",
     28 + .value_name = NULL},
     29 +};
     30 + 
    18 31  cfg_opt_t repository_opts[] = {CFG_STR("addr", ZIIT_DEFAULT_ADDR, CFGF_NONE),
    19 32   CFG_INT("port", ZIIT_DEFAULT_PORT, CFGF_NONE),
    20 33   CFG_STR("server_public_key", NULL, CFGF_NONE),
    skipped 4 lines
    25 38   CFGF_MULTI | CFGF_TITLE),
    26 39   CFG_FUNC("include", &cfg_include), CFG_END()};
    27 40   
     41 +static void print_help()
     42 +{
     43 + printf("Usage: ziit [OPTION...] <command>\n");
     44 + printf("Communicates with the ziit time tracking server.\n\n");
     45 + printf("Available commands:\n\n");
     46 + printf(" init: Initializes the repository configuration.\n");
     47 + printf(" status: Shows status information from the server.\n");
     48 + printf(" add: Adds a new entry to the time log.\n");
     49 + printf(" remove: Removes all entries within the interval.\n");
     50 + printf(" list: Lists entries in the specified interval.\n");
     51 + printf(
     52 + " summary: Creates a summary over all entries within the interval.\n");
     53 +}
     54 + 
     55 +static void print_version()
     56 +{
     57 + printf("ziit version v" ZIIT_VERSION "\n");
     58 +}
     59 + 
    28 60  int main(int argc, char *argv[])
    29 61  {
    30 62   int result;
     63 + cag_option_context ctx;
     64 + char identifier;
    31 65   const char *subprogram;
    32 66   char config_path[FILENAME_MAX];
    33 67   cfg_t *cfg;
     68 + 
     69 + if (argc == 2) {
     70 + cag_option_prepare(&ctx, options, CAG_ARRAY_SIZE(options), argc, argv);
     71 + while (cag_option_fetch(&ctx)) {
     72 + identifier = cag_option_get(&ctx);
     73 + switch (identifier) {
     74 + case 'v':
     75 + print_version();
     76 + return EXIT_SUCCESS;
     77 + case 'h':
     78 + print_help();
     79 + return EXIT_SUCCESS;
     80 + }
     81 + }
     82 + }
    34 83   
    35 84   cfg = cfg_init(opts, CFGF_NOCASE);
    36 85   
    skipped 29 lines
    66 115   } else if (strcmp(subprogram, "summary") == 0) {
    67 116   result = run_summary(argc, argv, cfg);
    68 117   } else {
    69  - printf("Unknown command.\n");
     118 + print_help();
     119 + return EXIT_FAILURE;
    70 120   }
    71 121   } else {
    72  - printf("ziit init, ziit add... \n");
     122 + print_help();
     123 + return EXIT_SUCCESS;
    73 124   }
    74 125   cfg_free(cfg);
    75 126   
    skipped 8 lines
  • src/remove.c
    ■ ■ ■ ■
    skipped 24 lines
    25 25   
    26 26  static void print_help()
    27 27  {
    28  - printf("Usage: ziit remove [-r <repository>] <interval>\n");
     28 + printf("Usage: ziit remove [OPTION...] <interval>\n");
    29 29   printf("Removes all entries within the interval.\n\n");
    30 30   cag_option_print(options, CAG_ARRAY_SIZE(options), stdout);
    31 31  }
    skipped 105 lines
  • src/summary.c
    ■ ■ ■ ■ ■ ■
    skipped 29 lines
    30 30   
    31 31  static void print_help()
    32 32  {
    33  - printf("Usage: ziit summary [-r <repository>] <interval>\n");
    34  - printf("Removes all entries within the interval.\n\n");
     33 + printf("Usage: ziit summary [OPTION...] <interval>\n");
     34 + printf("Creates a summary over all entries within the interval.\n\n");
    35 35   cag_option_print(options, CAG_ARRAY_SIZE(options), stdout);
    36 36  }
    37 37   
    skipped 262 lines
Page is in error, reload to recover