-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/add feature print configuration issue 172 #203
Open
zwdOr20
wants to merge
5
commits into
rdagumampan:master
Choose a base branch
from
zwdOr20:feature/Add-Feature-Print-Configuration-issue-172
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4f0d165
feat: Add Config command basic infra code
zwdOr20 620bd40
Complete feature : Configuration variables print
zwdOr20 3b20357
feat: Add Json Printer option (infra)
zwdOr20 57da2b7
feat: Complete feature : Add json option
zwdOr20 a88b385
refactor: Enhance code readability
zwdOr20 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using CommandLine; | ||
|
||
namespace Yuniql.CLI | ||
{ | ||
public class BaseConfigOption : BasePlatformOption | ||
{ | ||
//yuniql <command> -o json | ||
[Option('o', "output", Required = false, HelpText = "The choosen Output format")] | ||
public string Output { get; set; } | ||
|
||
//yuniql <command> -a true | --auto-create-db true | ||
[Option('a', "auto-create-db", Required = false, HelpText = "Create database automatically.")] | ||
public bool? IsAutoCreateDatabase { get; set; } | ||
} | ||
} | ||
|
||
|
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,9 @@ | ||
using CommandLine; | ||
|
||
namespace Yuniql.CLI | ||
{ | ||
[Verb("config", HelpText = "Print the environment setup in the command line")] | ||
public class ConfigOption : BaseConfigOption | ||
{ | ||
} | ||
} |
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,43 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Yuniql.Core; | ||
|
||
namespace Yuniql.CLI | ||
{ | ||
/// <summary> | ||
/// This class is used to print configuration variable as json text | ||
/// </summary> | ||
public class JsonPrinter : IPrinter | ||
{ | ||
private readonly string[] titles = new string[] { "property","value","source"}; | ||
private readonly List<string[]> rows = new List<string[]>(); | ||
|
||
public void AddRow(params object[] row) | ||
{ | ||
if (row.Length != titles.Length) | ||
{ | ||
throw new Exception($"Added row length [{row.Length}] is not equal to title row length [{titles.Length}]"); | ||
} | ||
rows.Add(row.Select(o => o.ToString()).ToArray()); | ||
} | ||
|
||
public void Print() | ||
rdagumampan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
var jarray = new JArray("Properties"); | ||
var jproperty = new JProperty("Properties", jarray); | ||
var jobject = new JObject(jproperty); | ||
foreach (var row in rows) | ||
{ | ||
JObject obj = new JObject(); | ||
for (int i = 0; i < row.Length; i++) | ||
{ | ||
obj.Add(new JProperty(titles[i], row[i])); | ||
} | ||
jarray.Add(obj); | ||
} | ||
Console.WriteLine(jobject.ToString()); | ||
} | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Yuniql.Core | ||
{ | ||
public interface IPrinter | ||
{ | ||
void Print(); | ||
void AddRow(params object[] row); | ||
|
||
} | ||
} |
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 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Yuniql.Core | ||
{ | ||
/// <summary> | ||
/// Information source for yuniql configuration values | ||
/// </summary> | ||
public enum Source | ||
{ | ||
/// <summary> | ||
/// Default value assigned to configuration parameter | ||
/// </summary> | ||
DEFAULT, | ||
/// <summary> | ||
/// Environment variable is the source of the configuration parameter | ||
/// </summary> | ||
ENVIRONMENT_VARIABLE, | ||
/// <summary> | ||
/// command line is the source of the configuration parameter | ||
/// </summary> | ||
CMD_LINE_OPTIONS | ||
} | ||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious why you think this has to be changed. I'm afraid it may introduce bugs not directly related to feature we're implementing. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The raison why I made it nullable is I want to differentiate between two states :
In both cases IsDebug set to false but the source of this false is different