-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathCommandScopes.cs
More file actions
47 lines (39 loc) · 1.39 KB
/
CommandScopes.cs
File metadata and controls
47 lines (39 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using McMaster.Extensions.CommandLineUtils;
using Microsoft.Authentication.AdoPat;
using Microsoft.Extensions.Logging;
using System;
using System.Linq;
namespace Microsoft.Authentication.AzureAuth.Commands.Ado.Pat
{
/// <summary>
/// Command to print the list of available scopes
/// </summary>
[Command("scopes", Description = "List the valid ado pat scopes")]
public class CommandScopes
{
private readonly ILogger logger;
private readonly string UrlMessage = $"See {AdoPat.Constants.PatListURL} for details.";
/// <summary>
/// Create a CommandScopes
/// </summary>
/// <param name="logger"></param>
public CommandScopes(ILogger<CommandScopes> logger)
{
this.logger = logger;
}
/// <summary>
/// Executes the Scopes command listing the available scopes
/// </summary>
/// <returns></returns>
public int OnExecute()
{
var scopes = Scopes.ValidScopes.ToList();
scopes.Sort();
// Print URL at the top and bottom because it's a long list of scopes.
logger.LogInformation(UrlMessage + "\n");
logger.LogInformation(string.Join(Environment.NewLine, scopes));
logger.LogInformation("\n" + UrlMessage);
return 0;
}
}
}