2 * Copyright (C) 2013-2014 Red Hat Inc.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 (* Stand-alone tool to read and modify the user's goaljobs memory. *)
27 printf " %s list\n" Sys.executable_name;
28 printf " %s [exists|get|delete] key\n" Sys.executable_name;
29 printf " %s set key value\n" Sys.executable_name;
30 printf "Subcommands:\n";
31 printf " exists - Check if key exists, exit code 0 if exists, 1 if not\n";
32 printf " get - Print the current value of the key\n";
33 printf " set - Set the key to a new value\n";
34 printf " delete - Delete the key\n";
35 printf " list - List the names and values of all keys\n";
39 match Array.to_list Sys.argv with
41 | [ ("--help" | "-h" | "-?") ] -> usage 0
42 | [ _; "exists"; key ] ->
43 if memory_exists key then exit 0 else exit 1
44 | [ _; "get"; key ] ->
45 (match memory_get key with
47 eprintf "%s: key '%s' not found in memory\n" Sys.executable_name key;
49 | Some v -> print_endline v
51 | [ _; "set"; key; value ] ->
53 | [ _; "delete"; key ] ->
56 let mem = memory_list () in
57 List.iter (fun (key, value) -> printf "%s\t%s\n" key value) mem