public override void Execute(IEnumerable <string> args) { IPackageFeed source = null; string version = null; var input = new OptionSet { { "i|installed", value => source = PackageManager.CacheFeed }, { "s=|source=", value => source = new PackageManager(Log).GetSource(value) }, { "n=|version=", value => version = value } }.Parse(args); if (source == null) { source = new PackageManager(Log); } input.CheckArguments(); FilterPackageArguments(input, ref version, ref source); Log.StartAnimation(); var first = true; foreach (var p in source.FindPackages(input, version)) { if (first) { WriteHead("Package".PadRight(32) + " " + "Version".PadRight(32) + " Source"); first = false; } WriteLine(p.Name.PadRight(32) + " " + p.Version.PadRight(32) + " " + p.Source); } if (first) { throw new ArgumentException("No packages found"); } }
public override void Execute(IEnumerable <string> args) { var asm = false; var libs = false; var system = false; var input = new OptionSet { { "a|asm", value => asm = true }, { "l|libs", value => libs = true }, { "s|sys|system", value => system = true } }.Parse(args); if (input.Count > 0) { input.CheckArguments(); foreach (var key in input) { WriteLine(UnoConfig.Current.GetString(key) ?? "(null)"); } return; } if (Log.IsVerbose) { WriteProductInfo(); } else { Log.ProductHeader(); } WriteHead("Uno settings", indent: 0); WriteRow(UnoConfig.Current); WriteHead("Config files", indent: 0); foreach (var f in UnoConfig.Current.GetFilenames(Log.IsVerbose)) { WriteRow(f.ToRelativePath()); } WriteHead("Config defines", indent: 0); var defines = UnoConfigFile.Defines.ToArray(); Array.Sort(defines); WriteLine(string.Join(" ", defines)); if (asm || Log.IsVerbose) { WriteHead(".NET assemblies", indent: 0); var configAssembly = typeof(Config).Assembly; var configVersion = configAssembly.GetName().Version; foreach (var f in GetDotNetAssemblies(configAssembly)) { if (f.GetName().Version != configVersion) { WriteRow(f.Location.ToRelativePath() + " (" + f.GetName().Version + ")"); } } } if (libs || Log.IsVerbose) { WriteHead("Uno libraries", 28, 0); foreach (var lib in GetUnoLibraries()) { WriteRow(lib.Name, lib.Location.ToRelativePath(), parse: false); } } if (system || Log.IsVerbose) { WriteHead("System settings", 24, 0); foreach (DictionaryEntry e in Environment.GetEnvironmentVariables()) { WriteRow(e.Key, e.Value, parse: false); } } }
public override void Execute(IEnumerable <string> args) { var force = false; string projectName = null; string className = null; var empty = false; var flatten = false; var defaults = false; var input = new OptionSet { { "c|class=", value => className = value }, { "n|name=", value => projectName = value }, { "d|defaults", value => defaults = true }, { "e|empty", value => empty = true }, { "f|force", value => force = true }, { "flatten", value => flatten = true } }.Parse(args); if (input.Count == 0) { input.Add("."); } else { input.CheckArguments(); } if (input.Count != 1 || string.IsNullOrWhiteSpace(input[0])) { throw new ArgumentException("Expected one project [file|directory]"); } var fullName = input[0].ToFullPath(); if (projectName == null) { projectName = Path.GetFileName(fullName); } if (!fullName.ToUpperInvariant().EndsWith(".UNOPROJ")) { fullName = Path.Combine(fullName, projectName + ".unoproj"); } if (Directory.Exists(fullName)) { throw new Exception(fullName.Quote() + " is a directory"); } if (!force && File.Exists(fullName)) { throw new Exception(fullName.Quote() + " already exists"); } var dirName = Path.GetDirectoryName(fullName); Disk.CreateDirectory(dirName); WriteLine("Creating project " + fullName.Quote()); var project = new Project(fullName); if (defaults) { project.AddDefaults(); } if (!empty) { project.MutableIncludeItems.Add("*"); foreach (var e in project.Config.GetStringArray("Packages.Default") ?? new string[0]) { project.MutablePackageReferences.Add(e); } } if (className != null) { var fileName = Path.Combine(project.RootDirectory, className + ".uno"); WriteEmptyClass(className, project.Name, fileName); if (empty) { project.MutableIncludeItems.Add(className + ".uno"); } } if (flatten) { project.FlattenItems(Log); } project.Save(); }
public override void Execute(IEnumerable <string> args) { var asm = false; var system = false; var input = new OptionSet { { "a|asm", value => asm = true }, { "s|sys|system", value => system = true } }.Parse(args); if (input.Count > 0) { input.CheckArguments(); foreach (var key in input) { WriteLine(UnoConfig.Current.GetString(key) ?? "(null)"); } return; } if (Log.IsVerbose) { WriteProductInfo(); } else { Log.ProductHeader(); } WriteHead("Uno settings", indent: 0); WriteRow(UnoConfig.Current); WriteHead("Config files", indent: 0); var files = new List <string>(); foreach (var f in UnoConfig.Current.Files) { files.Add(f.Stuff.Filename); f.Stuff.Flatten( filename => { if (!files.Contains(filename) || Log.IsVerbose) { files.Add(filename); } return(File.ReadAllText(filename)); }); } foreach (var f in files) { WriteRow(f.ToRelativePath()); } if (asm || Log.IsVerbose) { WriteHead(".NET assemblies", indent: 0); var configAssembly = typeof(Config).Assembly; var configVersion = configAssembly.GetName().Version; foreach (var f in GetAllAssemblies(configAssembly)) { if (f.GetName().Version != configVersion) { WriteRow(f.Location.ToRelativePath() + " (" + f.GetName().Version + ")"); } } } if (system || Log.IsVerbose) { WriteHead("System settings", 24, 0); foreach (DictionaryEntry e in Environment.GetEnvironmentVariables()) { WriteRow(e.Key, e.Value, parse: false); } } }
public override void Execute(IEnumerable <string> args) { string version = null; IPackageFeed source = null; var force = false; var input = new OptionSet { { "n=|version=", value => version = value }, { "f|force", value => force = true } }.Parse(args); if (input.Count == 0) { throw new ArgumentException("No packages specified"); } input.CheckArguments(); Feed.FilterPackageArguments(input, ref version, ref source); var cache = new PackageCache(); var versions = new List <DirectoryInfo>(); foreach (var package in input) { versions.AddRange(cache.EnumerateVersions(package, version)); } if (versions.Count == 0) { if (force) { return; } throw new ArgumentException("No packages found"); } if (!force && versions.Count > 1) { foreach (var dir in versions) { WriteLine(dir.FullName.ToRelativePath()); } if (!Confirm("The search returned more than one package -- delete all of them?")) { return; } } foreach (var dir in versions) { Disk.DeleteDirectory(dir.FullName, true); } // Delete any remaining empty directories foreach (var package in input) { foreach (var dir in cache.EnumeratePackages(package)) { if (dir.EnumerateFileSystemInfos().FirstOrDefault() == null) { Disk.DeleteDirectory(dir.FullName, true); } } } }