Skip to content
This repository
Browse code

Adding list-style output to crange

On the odd chance you need to have a list of nodes instead of a cvs with
collapsed number ranges
  • Loading branch information...
commit 0f13919748f00d11e211e7929d3e4135ab58d18f 1 parent 7b2f33a
Grier Johnson grierj authored

Showing 1 changed file with 31 additions and 2 deletions. Show diff stats Hide diff stats

  1. +31 2 libcrange/source/src/main.c
33 libcrange/source/src/main.c
@@ -12,13 +12,42 @@ int main(int argc, char const* const* argv)
12 12 {
13 13 apr_pool_t* pool;
14 14 struct range_request* rr;
  15 + const char **nodes;
  16 + int expand_flag = 0;
  17 + int c;
15 18
16 19 apr_app_initialize(&argc, &argv, NULL);
17 20 atexit(apr_terminate);
18 21 apr_pool_create(&pool, NULL);
19 22
20   - rr = range_expand(NULL, pool, argv[1]);
21   - printf("%s\n", range_request_compressed(rr));
  23 + while ((c = getopt (argc, argv, "e")) != -1) {
  24 + switch (c)
  25 + {
  26 + case 'e':
  27 + expand_flag = 1;
  28 + break;
  29 + case '?':
  30 + fprintf (stderr, "Usage: crange [-e] <range>\n\n");
  31 + return 1;
  32 + default:
  33 + abort ();
  34 + }
  35 + }
  36 +
  37 + if (argc > 3) {
  38 + fprintf (stderr, "Usage: crange [-e] <range>\n\n");
  39 + return 1;
  40 + }
  41 +
  42 + rr = range_expand(NULL, pool, argv[argc-1]);
  43 + if (expand_flag == 1) {
  44 + nodes = range_request_nodes(rr);
  45 + while (*nodes) {
  46 + printf("%s\n", *nodes++);
  47 + }
  48 + } else {
  49 + printf("%s\n", range_request_compressed(rr));
  50 + }
22 51
23 52 if (range_request_has_warnings(rr))
24 53 printf("%s\n", range_request_warnings(rr));

0 comments on commit 0f13919

Please sign in to comment.
Something went wrong with that request. Please try again.