monotone

monotone Mtn Source Tree

Root/src/options_applicator.cc

1// Copyright (C) 2010, 2012 and later by various people
2// see monotone commit logs for details and authors
3//
4// This program is made available under the GNU GPL version 2.0 or
5// greater. See the accompanying file COPYING for details.
6//
7// This program is distributed WITHOUT ANY WARRANTY; without even the
8// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9// PURPOSE.
10
11#include "base.hh"
12#include "options_applicator.hh"
13
14#include "options.hh"
15#include "sanity.hh"
16#include "ui.hh"
17
18class options_applicator_impl
19{
20public:
21 options_applicator::for_what what;
22 bool were_timestamps_enabled;
23 int prev_verbosity;
24 user_interface::ticker_type tick_type;
25};
26
27options_applicator::options_applicator(options const & opts,
28 options_applicator::for_what what)
29 : _impl(new options_applicator_impl())
30{
31 _impl->what = what;
32
33 // --dump is handled in monotone.cc
34 // --log is handled in monotone.cc
35 // -v is handled in monotone.cc
36
37 _impl->were_timestamps_enabled = ui.enable_timestamps(opts.timestamps);
38
39 // debug messages are not captured for automate, so don't allow
40 // changing the debug-ness for automate commands
41 _impl->prev_verbosity = global_sanity.set_verbosity(opts.verbosity,
42 what == for_primary_cmd);
43
44 _impl->tick_type = ui.get_ticker_type();
45 if (global_sanity.get_verbosity() < 0)
46 ui.set_tick_write_nothing();
47 else
48 {
49 if (opts.ticker == "none")
50 ui.set_tick_write_nothing();
51 else if (opts.ticker == "dot")
52 ui.set_tick_write_dot();
53 else if (opts.ticker == "count")
54 ui.set_tick_write_count();
55 else if (opts.ticker == "stdio")
56 ui.set_tick_write_stdio();
57 else
58 I(opts.ticker.empty());
59 }
60}
61
62options_applicator::~options_applicator()
63{
64 ui.enable_timestamps(_impl->were_timestamps_enabled);
65
66 global_sanity.set_verbosity(_impl->prev_verbosity, false);
67
68 ui.set_ticker_type(_impl->tick_type);
69
70 delete _impl;
71}
72
73// Local Variables:
74// mode: C++
75// fill-column: 76
76// c-file-style: "gnu"
77// indent-tabs-mode: nil
78// End:
79// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status