< Summary

Class:Mklinker.Commands.ConfigCommand
Assembly:Mklinker
File(s):/home/travis/build/rubenchristoffer/Mklinker/Mklinker/Commands/ConfigCommand.cs
Covered lines:43
Uncovered lines:1
Coverable lines:44
Total lines:68
Line coverage:97.7% (43 of 44)
Covered branches:16
Total branches:16
Branch coverage:100% (16 of 16)

Metrics

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

File(s)

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

#LineLine coverage
 1using System;
 2using System.Linq;
 3using CommandLine;
 4using Mklinker.Abstractions;
 5
 6namespace Mklinker.Commands {
 7
 8  [Verb("config", HelpText = "Displays information about config file by default, but can create / delete / modify config
 9  class ConfigCommand : GlobalOptions {
 10
 11    [Option ('c', "create", HelpText = "Creates a new config file if it does not exist", SetName = "Create")]
 1412    public bool create { get; private set; }
 13
 14    [Option('d', "delete", HelpText = "Deleted config file if it exists", SetName = "Delete")]
 1215    public bool delete { get; private set; }
 16
 017    public ConfigCommand() : base() {}
 18
 1419    public ConfigCommand (bool create, bool delete, string path) : base(path) {
 720      this.create = create;
 721      this.delete = delete;
 722    }
 23
 724    internal void Execute(IConsole console, IConfigHandler configHandler, IConfig defaultConfig, IPathResolver pathResol
 925      if (create) {
 326        if (configHandler.DoesConfigExist(path)) {
 127          console.WriteLine("Config already exists!", IConsole.ContentType.Negative);
 228        } else {
 129          console.WriteLine("Creating config '{0}'", path);
 30
 131          configHandler.SaveConfig(defaultConfig, path);
 132        }
 933      } else if (delete) {
 334        if (configHandler.DoesConfigExist(path)) {
 135          console.WriteLine("Deleting config '{0}'", path);
 136          configHandler.DeleteConfig(path);
 237        } else {
 138          console.WriteLine($"Config '{path}' does not exist!", IConsole.ContentType.Negative);
 139        }
 540      } else {
 541        if (configHandler.DoesConfigExist(path)) {
 242          IConfig config = configHandler.LoadConfig(path);
 43
 244          console.WriteLine();
 245          console.WriteLine("### Metadata info ###", IConsole.ContentType.Header);
 246          console.WriteLine($"Path: {path}");
 247          console.WriteLine($"Full path: {pathResolver.GetAbsoluteResolvedPath(path, config.Variables)}");
 248          console.WriteLine($"Version: {config.Version}");
 249          console.WriteLine();
 50
 251          console.WriteLine("### Variable info ###", IConsole.ContentType.Header);
 252          console.WriteLine("Total variables: " + config.Variables.Count);
 253          console.WriteLine();
 54
 255          console.WriteLine("### Link info ###", IConsole.ContentType.Header);
 256          console.WriteLine("Total links: " + config.LinkList.Count);
 357          console.WriteLine("Junction links: " + config.LinkList.Count(l => l.linkType == ConfigLink.LinkType.Junction))
 358          console.WriteLine("Symbolic links: " + config.LinkList.Count(l => l.linkType == ConfigLink.LinkType.Symbolic))
 359          console.WriteLine("Hard links: " + config.LinkList.Count(l => l.linkType == ConfigLink.LinkType.Hard));
 360        } else {
 161          console.WriteLine("Config does not exist. You can create one with the --create option.", IConsole.ContentType.
 162        }
 363      }
 764    }
 65
 66  }
 67
 68}