helper: Print /modules when verbose >= 2
[febootstrap.git] / febootstrap_cmdline.ml
1 (* febootstrap 3
2  * Copyright (C) 2009-2010 Red Hat Inc.
3  *
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.
8  *
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.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  *)
18
19 open Printf
20
21 let excludes = ref []
22 let names_mode = ref false
23 let outputdir = ref "."
24 let packages = ref []
25 let verbose = ref false
26 let warnings = ref true
27 let yum_config = ref None
28
29 let print_version () =
30   printf "%s %s\n" Config.package_name Config.package_version;
31   exit 0
32
33 let add_exclude re =
34   excludes := Str.regexp re :: !excludes
35
36 let set_yum_config str =
37   yum_config := Some str
38
39 let argspec = Arg.align [
40   "--exclude", Arg.String add_exclude,
41     "regexp Exclude packages matching regexp";
42   "--names", Arg.Set names_mode,
43     " Specify set of root package names on command line";
44   "--no-warnings", Arg.Clear warnings,
45     " Suppress warnings";
46   "-o", Arg.Set_string outputdir,
47     "outputdir Set output directory (default: \".\")";
48   "-v", Arg.Set verbose,
49     " Enable verbose output";
50   "--verbose", Arg.Set verbose,
51     " Enable verbose output";
52   "-V", Arg.Unit print_version,
53     " Print package name and version, and exit";
54   "--version", Arg.Unit print_version,
55     " Print package name and version, and exit";
56   "--yum-config", Arg.String set_yum_config,
57     "file Set alternate yum configuration file";
58 ]
59 let anon_fn str =
60   packages := str :: !packages
61
62 let usage_msg =
63   "\
64 febootstrap - bootstrapping tool for creating supermin appliances
65 Copyright (C) 2009-2010 Red Hat Inc.
66
67 Usage:
68  febootstrap [-o OUTPUTDIR] --names LIST OF PKGS ...
69  febootstrap [-o OUTPUTDIR] PKG FILE NAMES ...
70
71 For full instructions see the febootstrap(8) man page.
72
73 Options:\n"
74
75 let () =
76   Arg.parse argspec anon_fn usage_msg;
77   if !packages = [] then (
78     eprintf "febootstrap: no packages listed on the command line\n";
79     exit 1
80   )
81
82 let excludes = List.rev !excludes
83 let names_mode = !names_mode
84 let outputdir = !outputdir
85 let packages = List.rev !packages
86 let verbose = !verbose
87 let warnings = !warnings
88 let yum_config = !yum_config
89
90 let debug fs = ksprintf (fun str -> if verbose then print_endline str) fs