-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from LittleVaaty/18-retrieve-desktop-info
Add get-name and total commands + --on support name or index
- Loading branch information
Showing
29 changed files
with
261 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
using McMaster.Extensions.CommandLineUtils; | ||
using Microsoft.Extensions.Logging; | ||
using VDesk.Interop; | ||
using IConsole = VDesk.Utils.IConsole; | ||
|
||
namespace VDesk.Commands; | ||
|
||
public class GetNameCommand(ILogger<GetNameCommand> logger, IVirtualDesktopProvider virtualDesktopProvider, IConsole console) | ||
: VdeskCommandBase(logger, virtualDesktopProvider) | ||
{ | ||
[Option("-o|--on", CommandOptionType.SingleValue, Description = "Desktop on witch the command is run")] | ||
[Range(1, 10)] | ||
public int? DesktopNumber { get; set; } | ||
|
||
protected override int Execute(CommandLineApplication app) | ||
{ | ||
var desktopIds = VirtualDesktopProvider.GetDesktop(); | ||
|
||
if (DesktopNumber is not null) | ||
{ | ||
var name = VirtualDesktopProvider.GetDesktopName(desktopIds[DesktopNumber.Value - 1]); | ||
name = string.IsNullOrEmpty(name) ? $"Desktop {DesktopNumber}" : name; | ||
console.WriteLine($"The name of desktop {DesktopNumber} is {name}"); | ||
return 0; | ||
} | ||
|
||
for (var i = 0; i < desktopIds.Count; i++) | ||
{ | ||
var name = VirtualDesktopProvider.GetDesktopName(desktopIds[i]); | ||
name = string.IsNullOrEmpty(name) ? $"Desktop {i + 1}" : name; | ||
console.WriteLine($"The name of desktop {i + 1} is {name}"); | ||
} | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using McMaster.Extensions.CommandLineUtils; | ||
using Microsoft.Extensions.Logging; | ||
using VDesk.Interop; | ||
using IConsole = VDesk.Utils.IConsole; | ||
|
||
namespace VDesk.Commands; | ||
|
||
[Command(Description = "Get the total number of desktop")] | ||
public class TotalCommand(ILogger<TotalCommand> logger, IVirtualDesktopProvider virtualDesktopProvider, IConsole console) | ||
: VdeskCommandBase(logger, virtualDesktopProvider) | ||
{ | ||
protected override int Execute(CommandLineApplication app) | ||
{ | ||
var desktopIds = VirtualDesktopProvider.GetDesktop(); | ||
console.WriteLine($"Number of desktopIds: {desktopIds.Count}"); | ||
|
||
return 0; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.