// Config bool ConfigOperation(WrenchProject proj, BuildServices bs) { Result res = bs.GetValue().Result; if (res == null) { return(true); } // prompt Result rprompt; if (bs.GetTag("prompt", out rprompt)) { return(true); } string prompt; if (rprompt == null) { log.PushLocation(bs.FullName); log.Warning(2017, "This configurable option does not have a \'prompt\' tag.", null); log.PopLocation(); prompt = String.Format("Set value of {0}:", bs.FullName); } else { // TODO: i18n prompt = ((MBString)rprompt).Value; } if (res is MBBool) { DoConfigBool(prompt, (MBBool)res); } else if (res is MBString) { DoConfigString(prompt, (MBString)res); } else if (res is MBDirectory) { DoConfigDirectory(prompt, (MBDirectory)res); } else { string s = String.Format("Current value is {0}", res); log.PushLocation(bs.FullName); log.Error(2018, "Don't know how to configure this option.", s); log.PopLocation(); return(true); } bs.FixValue(res); return(false); }
// basic operations bool ShowOperation(WrenchProject proj, BuildServices bs) { Result res = bs.GetValue().Result; if (res != null) { Console.WriteLine("{0} = {1}", bs.FullName, res); } else { Console.WriteLine("{0} couldn't be evaluated.", bs.FullName); } return(false); }
bool LoadConfigItem(WrenchProject proj, BuildServices bs) { string prompt, group; string target = bs.FullName; Result res = bs.GetValue().Result; if (res == null) { return(true); } Result tag; if (bs.GetTag("prompt", out tag)) { return(true); } MBString rstr = tag as MBString; if (rstr == null) { // FIXME Console.Error.WriteLine("Configurable option " + target + " does not have a string \'prompt\' tag."); prompt = target; } else { // TODO: i18n prompt = rstr.Value; } if (bs.GetTag("config_group", out tag)) { return(true); } rstr = tag as MBString; if (rstr == null) { group = DefaultGroupName; } else { // TODO: i18n group = rstr.Value; } Widget widget = null; if (res is MBBool) { widget = MakeBoolItem(bs, prompt, (MBBool)res); } else if (res is MBString) { widget = MakeStringItem(bs, prompt, (MBString)res); } else { // FIXME Console.Error.WriteLine("Don't know how to configure the option {0}.", target); return(true); } AddGuiItem(group, widget); return(false); }