diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-04-20 10:39:19 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-04-20 10:39:19 +0300 |
commit | 67dce06bb26798e2b11ee0883bdc7e08d7edb663 (patch) | |
tree | 3f3655179dded2bbdd16c411d3f0558fe4515bf9 /src/mktags-cl.opt | |
parent | 347387193da605922ed98742dbc7fa3f67a908f4 (diff) | |
download | eclat-67dce06bb26798e2b11ee0883bdc7e08d7edb663.tar.gz eclat-67dce06bb26798e2b11ee0883bdc7e08d7edb663.tar.bz2 |
Major rewrite. Provide short names for each command.
Diffstat (limited to 'src/mktags-cl.opt')
-rw-r--r-- | src/mktags-cl.opt | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/src/mktags-cl.opt b/src/mktags-cl.opt new file mode 100644 index 0000000..0ca52e3 --- /dev/null +++ b/src/mktags-cl.opt @@ -0,0 +1,97 @@ +/* This file is part of Eclat. + Copyright (C) 2012, 2013 Sergey Poznyakoff. + + Eclat is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + Eclat is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Eclat. If not, see <http://www.gnu.org/licenses/>. */ + +static char *from_file; +static struct grecs_list *reslist; + +struct resource { + char *map; + char *resid; +}; + +OPTIONS_BEGIN("eclat create-tags", + [<create tags for the specified resources>], + [<TAG[=VALUE] [TAG[=VALUE...]]>], + [<gnu>], + [<nousage>], + [<noversion>]) + +OPTION(resource-id,r,[<[MAP:]ID>], + [<resource for which to create the tags>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + char *p = strchr(optarg, ':'); + if (p) { + res->map = optarg; + *p++ = 0; + res->resid = p; + } else { + res->map = NULL; + res->resid = optarg; + } + grecs_list_append(reslist, res); +END + +OPTION(instance,i,[<ID>], + [<instance ID>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + res->map = "InstanceId"; + res->resid = optarg; + grecs_list_append(reslist, res); +END + +OPTION(volume,v,[<ID>], + [<volume ID>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + res->map = "VolumeId"; + res->resid = optarg; + grecs_list_append(reslist, res); +END + +OPTION(ami,a,[<ID>], + [<AMI ID>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + res->map = "ImageId"; + res->resid = optarg; + grecs_list_append(reslist, res); +END + +OPTION(snapshot,s,[<ID>], + [<snapshot ID>]) +BEGIN + struct resource *res = grecs_malloc(sizeof(*res)); + res->map = "SnapshotId"; + res->resid = optarg; + grecs_list_append(reslist, res); +END + +OPTION(from-file,T,[<FILE>], + [<read tags from FILE>]) +BEGIN + from_file = optarg; +END + +OPTIONS_END + +static void +parse_options(int argc, char *argv[], int *index) +{ + reslist = grecs_list_create(); + GETOPT(argc, argv, *index, exit(EX_USAGE)) +} |