Intermediate commit
This commit is contained in:
parent
7a07cada25
commit
d5f883baca
@ -10,7 +10,7 @@ public partial class MycroForge
|
||||
public class Run : Command, ISubCommandOf<Api>
|
||||
{
|
||||
private readonly ProjectContext _context;
|
||||
|
||||
|
||||
public Run(ProjectContext context) : base("run", "Run your app")
|
||||
{
|
||||
_context = context;
|
||||
@ -19,9 +19,10 @@ public partial class MycroForge
|
||||
|
||||
private async Task ExecuteAsync()
|
||||
{
|
||||
var config = await _context.LoadConfig();
|
||||
await _context.Bash([
|
||||
"source .venv/bin/activate",
|
||||
"uvicorn main:app --reload"
|
||||
$"uvicorn main:app --port {config.Api.Port} --reload"
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,9 @@ public partial class MycroForge
|
||||
private static readonly Argument<IEnumerable<string>> PackagesArgument =
|
||||
new(name: "packages", description: "The names of the packages to uninstall");
|
||||
|
||||
private static readonly Option<bool> YesOption =
|
||||
new(aliases: ["-y", "--yes"], description: "Don’t ask for confirmation of uninstall deletions");
|
||||
|
||||
private readonly ProjectContext _context;
|
||||
|
||||
public Uninstall(ProjectContext context) : base("uninstall", "Uninstall packages and update the requirements.txt")
|
||||
@ -17,14 +20,15 @@ public partial class MycroForge
|
||||
_context = context;
|
||||
AddAlias("u");
|
||||
AddArgument(PackagesArgument);
|
||||
this.SetHandler(ExecuteAsync, PackagesArgument);
|
||||
AddOption(YesOption);
|
||||
this.SetHandler(ExecuteAsync, PackagesArgument, YesOption);
|
||||
}
|
||||
|
||||
private async Task ExecuteAsync(IEnumerable<string> packages)
|
||||
private async Task ExecuteAsync(IEnumerable<string> packages, bool yes)
|
||||
{
|
||||
await _context.Bash(
|
||||
"source .venv/bin/activate",
|
||||
$"pip uninstall {string.Join(' ', packages)}",
|
||||
$"pip uninstall{(yes ? " --yes " : " ")}{string.Join(' ', packages)}",
|
||||
"pip freeze > requirements.txt"
|
||||
);
|
||||
}
|
||||
|
@ -36,10 +36,10 @@ public class ProjectContext
|
||||
{
|
||||
var fullPath = Path.Combine(RootDirectory, path);
|
||||
|
||||
if (Directory.Exists(fullPath))
|
||||
if (!Directory.Exists(fullPath))
|
||||
{
|
||||
throw new(string.Join('\n',
|
||||
$"{path} does not exist, make sure your in the correct directory."
|
||||
$"{fullPath} does not exist, make sure you're in the correct directory."
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user