// Authors:
// Jonathan Pryor <jpryor@novell.com>
// Federico Di Gregorio <fog@initd.org>
+// Rolf Bjarne Kvinge <rolf@xamarin.com>
//
// Copyright (C) 2008 Novell (http://www.novell.com)
// Copyright (C) 2009 Federico Di Gregorio.
+// Copyright (C) 2012 Xamarin Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
OptionValueType type;
int count;
string[] separators;
+ bool hidden;
protected Option (string prototype, string description)
- : this (prototype, description, 1)
+ : this (prototype, description, 1, false)
{
}
protected Option (string prototype, string description, int maxValueCount)
+ : this (prototype, description, maxValueCount, false)
+ {
+ }
+
+ protected Option (string prototype, string description, int maxValueCount, bool hidden)
{
if (prototype == null)
throw new ArgumentNullException ("prototype");
return;
this.type = ParsePrototype ();
+ this.hidden = hidden;
if (this.count == 0 && type != OptionValueType.None)
throw new ArgumentException (
public string Description {get {return description;}}
public OptionValueType OptionValueType {get {return type;}}
public int MaxValueCount {get {return count;}}
+ public bool Hidden {get {return hidden;}}
public string[] GetNames ()
{
Action<OptionValueCollection> action;
public ActionOption (string prototype, string description, int count, Action<OptionValueCollection> action)
- : base (prototype, description, count)
+ : this (prototype, description, count, action, false)
+ {
+ }
+
+ public ActionOption (string prototype, string description, int count, Action<OptionValueCollection> action, bool hidden)
+ : base (prototype, description, count, hidden)
{
if (action == null)
throw new ArgumentNullException ("action");
}
public OptionSet Add (string prototype, string description, Action<string> action)
+ {
+ return Add (prototype, description, action, false);
+ }
+
+ public OptionSet Add (string prototype, string description, Action<string> action, bool hidden)
{
if (action == null)
throw new ArgumentNullException ("action");
Option p = new ActionOption (prototype, description, 1,
- delegate (OptionValueCollection v) { action (v [0]); });
+ delegate (OptionValueCollection v) { action (v [0]); }, hidden);
base.Add (p);
return this;
}
public OptionSet Add (string prototype, string description, OptionAction<string, string> action)
{
+ return Add (prototype, description, action, false);
+ }
+
+ public OptionSet Add (string prototype, string description, OptionAction<string, string> action, bool hidden) {
if (action == null)
throw new ArgumentNullException ("action");
Option p = new ActionOption (prototype, description, 2,
- delegate (OptionValueCollection v) {action (v [0], v [1]);});
+ delegate (OptionValueCollection v) {action (v [0], v [1]);}, hidden);
base.Add (p);
return this;
}
if (i == 0)
return false;
throw new OptionException (string.Format (localizer (
- "Cannot bundle unregistered option '{0}'."), opt), opt);
+ "Cannot use unregistered option '{0}' in bundle '{1}'."), rn, f + n), null);
}
p = this [rn];
switch (p.OptionValueType) {
foreach (Option p in this) {
int written = 0;
+ if (p.Hidden)
+ continue;
+
Category c = p as Category;
if (c != null) {
WriteDescription (o, p.Description, "", 80, 80);