• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

samsmithnz / DotNetCensus / 4773330594

pending completion
4773330594

Pull #90

github

GitHub
Merge 6991c8b68 into 0b3e1d200
Pull Request #90: Code gardening

444 of 486 branches covered (91.36%)

Branch coverage included in aggregate %.

75 of 75 new or added lines in 9 files covered. (100.0%)

912 of 959 relevant lines covered (95.1%)

934.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.97
/src/DotNetCensus/Program.cs
1
using CommandLine;
2
using DotNetCensus.Core.Models;
3

4
namespace DotNetCensus;
5

6
public class Program
7
{
8
    private static string? _directory;
9
    private static Repo? _repo;
10
    private static bool _includeTotals;
11
    private static bool _includeInventory;
12
    private static string? _file;
13

14
    public static void Main(string[] args)
15
    {
16
        //process arguments
17
        Parser.Default.ParseArguments<Options>(args)
14✔
18
               .WithParsed(RunOptions)
19
               .WithNotParsed(HandleParseError);
20

21
        //If there is a folder to scan, run the process against it
22
        if (!string.IsNullOrEmpty(_directory) || _repo != null)
15✔
23
        {
24
            if (_includeInventory)
5✔
25
            {
26
                Core.Main.GetInventoryResultsAsString(_directory, _repo, _file);
27
            }
28
            else
29
            {
30
                Core.Main.GetFrameworkSummaryAsString(_directory, _repo, _includeTotals, _file);
31
            }
32
        }
33
    }
34

35
    static void RunOptions(Options opts)
36
    {
37
        //handle options
38
        _directory = opts.Directory;
39

40
        //setup the GitHub repo details
41
        if (opts.Owner != null && opts.Repo != null)
12✔
42
        {
43
            _repo = new Repo(opts.Owner, opts.Repo)
44
            {
45
                User = opts.Repo, //This is not a typo - we are using the repo name as the user
46
                Password = opts.Password,
47
                Branch = opts.Branch
48
            };
49
        }
50
        if (_directory == null && _repo == null)
11✔
51
        {
52
            //If both directory and repo are null, use the current directory
53
            _directory = Directory.GetCurrentDirectory();
54
        }
55
        _includeTotals = opts.IncludeTotals;
56
        _includeInventory = opts.IncludeInventory;
57
        _file = opts.File;
58
    }
59

60
    static void HandleParseError(IEnumerable<Error> errs)
61
    {
62
        //handle errors
63
        var excList = new List<Exception>();
64
        foreach (var err in errs)
2✔
65
        {
66
            excList.Add(new ArgumentException(err.ToString()));
67
        }
68
        if (excList.Any())
1!
69
        {
70
            throw new AggregateException(excList);
71
        }
72
    }
73
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc