-
Notifications
You must be signed in to change notification settings - Fork 16
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 #592 from WildernessLabs/feature/source
added source code capabilities to CLIv2
- Loading branch information
Showing
12 changed files
with
526 additions
and
1 deletion.
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
24 changes: 24 additions & 0 deletions
24
Source/v2/Meadow.CLI/Commands/Current/Config/ConfigRouteCommand.cs
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,24 @@ | ||
using CliFx.Attributes; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("config route", Description = "Sets the communication route for HCOM")] | ||
public class ConfigRouteCommand : BaseSettingsCommand<ConfigCommand> | ||
{ | ||
[CommandParameter(0, Name = "Route", IsRequired = true)] | ||
public string Route { get; init; } | ||
|
||
public ConfigRouteCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(settingsManager, loggerFactory) | ||
{ } | ||
|
||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
Logger?.LogInformation($"{Environment.NewLine}Setting route={Route}"); | ||
SettingsManager.SaveSetting("route", Route); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
Source/v2/Meadow.CLI/Commands/Current/Config/ConfigSourceCommand.cs
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,40 @@ | ||
using CliFx.Attributes; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("config source", Description = "Sets the root folder for Meadow source directories")] | ||
public class ConfigSourceCommand : BaseSettingsCommand<ConfigCommand> | ||
{ | ||
[CommandParameter(0, Name = "Root", IsRequired = false)] | ||
public string? Root { get; init; } | ||
|
||
public ConfigSourceCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(settingsManager, loggerFactory) | ||
{ } | ||
|
||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
var root = Root; | ||
|
||
// if Root is null, as the user if they want to use the current folder | ||
if (string.IsNullOrWhiteSpace(Root)) | ||
{ | ||
System.Console.Write("No root folder provided. You you want to use the current directory? (y/n) "); | ||
if (System.Console.ReadLine()?.Trim() != "y") | ||
{ | ||
System.Console.WriteLine("cancelled"); | ||
return ValueTask.CompletedTask; | ||
} | ||
|
||
root = Environment.CurrentDirectory; | ||
} | ||
|
||
root!.Trim('\'').Trim('"'); ; | ||
Logger?.LogInformation($"{Environment.NewLine}Setting source={root}"); | ||
SettingsManager.SaveSetting("source", root!); | ||
|
||
return ValueTask.CompletedTask; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
Source/v2/Meadow.CLI/Commands/Current/Source/SourceCheckoutCommand.cs
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,29 @@ | ||
using CliFx.Attributes; | ||
using Meadow.Tools; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("source checkout", Description = "Pulls a single-named branch of all Meadow source repositories")] | ||
public class SourceCheckoutCommand : BaseCommand<AppBuildCommand> | ||
{ | ||
private ISettingsManager _settingsManager; | ||
|
||
[CommandParameter(0, Description = Strings.PathToMeadowProject, IsRequired = true)] | ||
public string Branch { get; init; } | ||
|
||
public SourceCheckoutCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
var root = new MeadowRoot(_settingsManager); | ||
|
||
root.Checkout(Branch); | ||
|
||
return default; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Source/v2/Meadow.CLI/Commands/Current/Source/SourceFetchCommand.cs
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,26 @@ | ||
using CliFx.Attributes; | ||
using Meadow.Tools; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("source fetch", Description = "Fetches each of the local Meadow source repositories")] | ||
public class SourceFetchCommand : BaseCommand<AppBuildCommand> | ||
{ | ||
private ISettingsManager _settingsManager; | ||
|
||
public SourceFetchCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
var root = new MeadowRoot(_settingsManager); | ||
|
||
root.Fetch(); | ||
|
||
return default; | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
Source/v2/Meadow.CLI/Commands/Current/Source/SourcePullCommand.cs
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,47 @@ | ||
using CliFx.Attributes; | ||
using Meadow.Tools; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("source clone", Description = "Clones any missing local Meadow source repositories")] | ||
public class SourceCloneCommand : BaseCommand<AppBuildCommand> | ||
{ | ||
private ISettingsManager _settingsManager; | ||
|
||
public SourceCloneCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
var root = new MeadowRoot(_settingsManager); | ||
|
||
root.Clone(); | ||
|
||
return default; | ||
} | ||
} | ||
|
||
[Command("source pull", Description = "Pulls each of the local Meadow source repositories")] | ||
public class SourcePullCommand : BaseCommand<AppBuildCommand> | ||
{ | ||
private ISettingsManager _settingsManager; | ||
|
||
public SourcePullCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
var root = new MeadowRoot(_settingsManager); | ||
|
||
root.Pull(); | ||
|
||
return default; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
Source/v2/Meadow.CLI/Commands/Current/Source/SourceStatusCommand.cs
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,26 @@ | ||
using CliFx.Attributes; | ||
using Meadow.Tools; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace Meadow.CLI.Commands.DeviceManagement; | ||
|
||
[Command("source status", Description = "Compares the local Meadow source repositories with the remotes")] | ||
public class SourceStatusCommand : BaseCommand<AppBuildCommand> | ||
{ | ||
private ISettingsManager _settingsManager; | ||
|
||
public SourceStatusCommand(ISettingsManager settingsManager, ILoggerFactory loggerFactory) | ||
: base(loggerFactory) | ||
{ | ||
_settingsManager = settingsManager; | ||
} | ||
|
||
protected override ValueTask ExecuteCommand() | ||
{ | ||
var root = new MeadowRoot(_settingsManager); | ||
|
||
root.Status(); | ||
|
||
return default; | ||
} | ||
} |
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,17 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="LibGit2Sharp" Version="0.30.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Meadow.Tooling.Core\Meadow.Tooling.Core.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.