-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Separate subcommands into separate classes
- Loading branch information
Nate McMaster
committed
Jul 13, 2016
1 parent
edb4b63
commit ecdf1a7
Showing
14 changed files
with
132 additions
and
75 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Extensions.CommandLineUtils; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Tools | ||
{ | ||
public class DatabaseCommand | ||
{ | ||
public static void Configure(CommandLineApplication command, CommandLineOptions options) | ||
{ | ||
command.Description = "Commands to manage your database"; | ||
command.HelpOption(); | ||
|
||
command.Command("update", c => DatabaseUpdateCommand.Configure(c, options)); | ||
command.Command("drop", c => DatabaseDropCommand.Configure(c, options)); | ||
|
||
command.OnExecute(() => | ||
{ | ||
EfCommand.WriteLogo(); | ||
command.ShowHelp(); | ||
}); | ||
} | ||
} | ||
} |
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,24 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Extensions.CommandLineUtils; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Tools | ||
{ | ||
public class DbContextCommand | ||
{ | ||
public static void Configure(CommandLineApplication command, CommandLineOptions options) | ||
{ | ||
command.Description = "Commands to manage your DbContext types"; | ||
command.HelpOption(); | ||
|
||
command.Command("list", c => DbContextListCommand.Configure(c, options)); | ||
command.Command("scaffold", c => DbContextScaffoldCommand.Configure(c, options)); | ||
command.OnExecute(() => | ||
{ | ||
EfCommand.WriteLogo(); | ||
command.ShowHelp(); | ||
}); | ||
} | ||
} | ||
} |
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,44 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System; | ||
using Microsoft.Extensions.CommandLineUtils; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Tools | ||
{ | ||
public static class EfCommand | ||
{ | ||
public static void Configure(CommandLineApplication app, CommandLineOptions options) | ||
{ | ||
app.Command("database", c => DatabaseCommand.Configure(c, options)); | ||
|
||
app.Command("dbcontext", c => DbContextCommand.Configure(c, options)); | ||
|
||
app.Command("migrations", c => MigrationsCommand.Configure(c, options)); | ||
|
||
app.OnExecute(() => | ||
{ | ||
WriteLogo(); | ||
app.ShowHelp(); | ||
}); | ||
} | ||
|
||
public static void WriteLogo() | ||
{ | ||
const string Bold = "\x1b[1m"; | ||
const string Normal = "\x1b[22m"; | ||
const string Magenta = "\x1b[35m"; | ||
const string White = "\x1b[37m"; | ||
const string Default = "\x1b[39m"; | ||
|
||
Console.WriteLine(); | ||
Console.WriteLine(@" _/\__ ".Insert(21, Bold + White)); | ||
Console.WriteLine(@" ---==/ \\ ".Insert(20, Bold + White)); | ||
Console.WriteLine(@" ___ ___ |. \|\ ".Insert(26, Bold).Insert(21, Normal).Insert(20, Bold + White).Insert(9, Normal + Magenta)); | ||
Console.WriteLine(@" | __|| __| | ) \\\ ".Insert(20, Bold + White).Insert(8, Normal + Magenta)); | ||
Console.WriteLine(@" | _| | _| \_/ | //|\\ ".Insert(20, Bold + White).Insert(8, Normal + Magenta)); | ||
Console.WriteLine(@" |___||_| / \\\/\\".Insert(33, Normal + Default).Insert(23, Bold + White).Insert(8, Normal + Magenta)); | ||
Console.WriteLine(); | ||
} | ||
} | ||
} |
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,26 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using Microsoft.Extensions.CommandLineUtils; | ||
|
||
namespace Microsoft.EntityFrameworkCore.Tools | ||
{ | ||
public class MigrationsCommand | ||
{ | ||
public static void Configure(CommandLineApplication command, CommandLineOptions options) | ||
{ | ||
command.Description = "Commands to manage your migrations"; | ||
command.HelpOption(); | ||
|
||
command.Command("add", c => MigrationsAddCommand.Configure(c, options)); | ||
command.Command("list", c => MigrationsListCommand.Configure(c, options)); | ||
command.Command("remove", c => MigrationsRemoveCommand.Configure(c, options)); | ||
command.Command("script", c => MigrationsScriptCommand.Configure(c, options)); | ||
command.OnExecute(() => | ||
{ | ||
EfCommand.WriteLogo(); | ||
command.ShowHelp(); | ||
}); | ||
} | ||
} | ||
} |
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