public static void Main(string[] args) { // TODO: Load plugins here var parameters = new StartParameters(); for (int i = 0; i < args.Length; i++) // TODO: Consider moving this out of this file { var arg = args[i]; try { if (arg.StartsWith("-")) { switch (arg) { case "--config": parameters.Configuration = args[++i]; break; case "--help": DisplayHelp(); return; case "--setup": parameters.RunSetup = true; break; default: Console.WriteLine("Invalid usage! Use Virtue.exe --help to get more information."); return; } } else { Console.WriteLine("Invalid usage! Use Virtue.exe --help to get more information."); return; } } catch { Console.WriteLine("Invalid usage! Use Virtue.exe --help to get more information."); return; } } if (!File.Exists(parameters.Configuration) || parameters.RunSetup) Setup.FirstTimeSetup(); else Configuration = Configuration.Load(parameters.Configuration); GitHubAPI.Login(Configuration.GitHubUsername, Configuration.GitHubPassword); }
public static void Run(Configuration config, Program instance) { var pluginFiles = Directory.GetFiles("plugins", "*.dll"); var descriptors = new List<PluginDescriptor>(pluginFiles.Select(f => PluginInformationGetter.GetInformation(Path.GetFileName(f))).Where(a => a != null).ToArray()); while (descriptors.Any()) { Console.WriteLine("The following plugins were found in the 'plugins' folder:"); for (int i = 0; i < descriptors.Count; i++) Console.WriteLine("[{0}] {1}: {2}", i, descriptors[i].FriendlyName, descriptors[i].Description); Console.WriteLine("[n]: None"); Console.WriteLine("Would you like to install any plugins?"); Console.WriteLine("Select a number:"); Console.Write("> "); var selection = Console.ReadLine(); if (selection == "n") break; int index; if (int.TryParse(selection, out index)) { if (index < descriptors.Count) { Console.WriteLine("Installed '{0}'", descriptors[index].FriendlyName); config.Plugins = config.Plugins.Concat(new[] { descriptors[index].BaseDll }).ToArray(); descriptors.RemoveAt(index); } } } instance.LoadPlugins(); // Install projects string input; do { Console.Write("Would you like to set up a project (yes/no)? "); input = Console.ReadLine(); if (input == "yes") { var project = SetUpProject(instance); } } while (input != "no"); }
public static void FirstTimeSetup() { // TODO: Consider refactoring // TODO: Alternate locales var config = new Configuration(); Console.WriteLine("Welcome to Virtue. Let's get started."); Console.WriteLine("We need a GitHub account to work with. Virtue is strongly GitHub-oriented."); Console.WriteLine("It is suggested that you create a seperate account for Virtue than your own."); AuthenticatedUser user; do { Console.Write("Username: "******"Password: "******"Try again."); } while (user == null); Program.Configuration = config; }
private bool DoSetup() { GenerateDirectories(); Log("No configuration file found."); Console.WriteLine("Would you like to run first-time setup (1), or generate an empty{0}configuration (2)?", Environment.NewLine); string choice; do { Console.Write("> "); choice = Console.ReadLine(); } while (choice != "1" && choice != "2"); Configuration = new Configuration(); if (choice == "1") { Setup.Run(Configuration, this); File.WriteAllText(ConfigurationFilePath, JsonConvert.SerializeObject(Configuration, Formatting.Indented)); Log("Configuration saved to '{0}'", ConfigurationFilePath); return true; } else { File.WriteAllText(ConfigurationFilePath, JsonConvert.SerializeObject(Configuration, Formatting.Indented)); Log("Blank configuration generated in {0}, edit and restart.", ConfigurationFilePath); return false; } }