public override async Task <int> ExecuteAsync() { DependencyType type = _options.Type.ToLower() == "toolset" ? DependencyType.Toolset : DependencyType.Product; Local local = new Local(LocalCommands.GetGitDir(Logger), Logger); DependencyDetail dependency = new DependencyDetail { Name = _options.Name, Version = _options.Version ?? string.Empty, RepoUri = _options.RepoUri ?? string.Empty, Commit = _options.Commit ?? string.Empty }; try { await local.AddDependenciesAsync(dependency, type); return(Constants.SuccessCode); } catch (Exception exc) { Logger.LogError(exc, $"Something failed while adding dependency '{dependency.Name}' {dependency.Version}."); return(Constants.ErrorCode); } }
public override async Task <int> ExecuteAsync() { Local local = new Local(LocalCommands.GetGitDir(Logger), Logger); try { IEnumerable <DependencyDetail> dependencies = await local.GetDependenciesAsync(_options.Name); if (!string.IsNullOrEmpty(_options.Name)) { DependencyDetail dependency = dependencies.Where(d => d.Name.Equals(_options.Name, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault(); if (dependency == null) { throw new Exception($"A dependency with name '{_options.Name}' was not found..."); } LogDependency(dependency); } foreach (DependencyDetail dependency in dependencies) { LogDependency(dependency); Console.WriteLine(); } return(Constants.SuccessCode); } catch (Exception exc) { if (!string.IsNullOrEmpty(_options.Name)) { Logger.LogError(exc, $"Something failed while querying for local dependency '{_options.Name}'."); } else { Logger.LogError(exc, "Something failed while querying for local dependencies."); } return(Constants.ErrorCode); } }