< Summary

Class:Mklinker.Commands.ListCommand
Assembly:Mklinker
File(s):/home/travis/build/rubenchristoffer/Mklinker/Mklinker/Commands/ListCommand.cs
Covered lines:23
Uncovered lines:9
Coverable lines:32
Total lines:58
Line coverage:71.8% (23 of 32)
Covered branches:10
Total branches:12
Branch coverage:83.3% (10 of 12)

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.ctor()100%100%
.ctor(...)10100%100%
Execute(...)12073.07%83.33%

File(s)

/home/travis/build/rubenchristoffer/Mklinker/Mklinker/Commands/ListCommand.cs

#LineLine coverage
 1using System;
 2using System.IO.Abstractions;
 3using CommandLine;
 4using Mklinker.Abstractions;
 5
 6namespace Mklinker.Commands {
 7
 8  [Verb ("list", HelpText = "Lists all the links or variables in the config")]
 9  class ListCommand : GlobalOptions {
 10
 11    [Option('v', "variables", HelpText = "Will display variables instead", Required = false, Default = false)]
 612    public bool displayVariables { get; private set; }
 13
 14    [Option('a', "absolute", HelpText = "Will display absolute paths with variables resolved", Required = false, Default
 015    public bool displayAbsolutePaths { get; private set; }
 16
 017    public ListCommand() : base() {}
 18
 619    public ListCommand(bool displayVariables, string path) : base(path) {
 320      this.displayVariables = displayVariables;
 321    }
 22
 323    internal void Execute(IConsole console, IConfigHandler configHandler, IFileSystem fileSystem, IPathResolver pathReso
 024      if (!configHandler.DoesConfigExist(path)) {
 025        console.WriteLine($"Config '{ path }' does not exist. Type 'help config' in order to see how you create a config
 026        return;
 27      }
 28
 329      IConfig config = configHandler.LoadConfig(path);
 30
 531      if (!displayVariables) {
 1232        foreach (ConfigLink configLink in config.LinkList) {
 233          string absoluteSourcePathString = "";
 234          string absoluteTargetPathString = "";
 35
 036          if (displayAbsolutePaths) {
 037            absoluteSourcePathString = $"\n\t\t  => { pathResolver.GetAbsoluteResolvedPath(configLink.sourcePath, config
 038            absoluteTargetPathString = $"\n\t\t  => { pathResolver.GetAbsoluteResolvedPath(configLink.targetPath, config
 039          }
 40
 241          console.WriteLine($"\n" +
 242            $"{ configLink.linkType.ToString() } link:\n" +
 243            $"\t- Source: { configLink.sourcePath }{ absoluteSourcePathString }\n" +
 244            $"\t- Target: { configLink.targetPath }{ absoluteTargetPathString }\n");
 245        }
 346      } else {
 947        foreach (Variable variable in config.Variables) {
 248          console.WriteLine($"\n { variable.ToString() }");
 249        }
 150      }
 51
 352      if (config.LinkList.Count == 0)
 253        console.WriteLine("Config is empty");
 354    }
 55
 56  }
 57
 58}