Skip to content
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

Add SKonsole configuration command and Spectre.Console package #3

Merged
merged 5 commits into from
Aug 15, 2023

Conversation

xbotter
Copy link
Contributor

@xbotter xbotter commented Aug 9, 2023

Summary:
This pull request updates the SKonsole project with the addition of a new configuration command and the Spectre.Console package. The new "config" command allows users to manage configuration settings for the application, including getting and setting specific configuration keys. The configuration values are stored in a file named ".skonsole". Additionally, the Spectre.Console package is added as a new package reference to enhance the user interface with interactive prompts and colored output.

Changes:

  • Added a new command, "config", to the SKonsole application.
  • Implemented subcommands for getting and setting configuration values.
  • Created a ConfigurationProvider class to handle reading and writing configuration values.
  • Added a new file, "ConfigCommand.cs", to handle the "config" command logic.
  • Added a new file, "ConfigurationProvider.cs", to handle reading and writing configuration values.
  • Modified the "Program.cs" file to include the new "config" command and its subcommands.
  • Updated the "ConfigCommand.cs" file to handle getting and setting configuration values.
  • Updated the "Program.cs" file to use the ConfigurationProvider class to get and set configuration values.
  • Added validation and error handling for empty configuration values.
  • Updated the "Program.cs" file to use the Spectre.Console library for interactive prompts and colored output.

Note: This pull request focuses on adding the new "config" command and its related functionality, as well as integrating the Spectre.Console package for improved user interface. Other changes in the diff are related to existing functionality and are not directly related to the new command.

xbotter added 4 commits August 8, 2023 20:54
✨ Added a new file `ConfigurationProvider.cs` that implements a configuration provider.
- The `ConfigurationProvider` class reads and saves configuration settings from a file named `.skonsole` in the user's profile directory.
- The configuration settings are stored in a dictionary and can be accessed using the `Get` method.
- The `SaveConfig` method allows saving new configuration settings.
- The class uses the `Microsoft.Extensions.Configuration` package for configuration management.
- The class also includes helper methods for serializing and deserializing JSON.

🔀 Add support for multi-line input in SKonsole

✨ Add support for multi-line input in the SKonsole application by implementing the ReadMutiLineInput() method. This allows users to input multiple lines of text instead of just a single line. The method reads input from the console until an empty line is entered, concatenating each line with a newline character. This change improves the user experience and enables more complex interactions with the application.

📝 Summary:
- Added support for multi-line input in SKonsole application
- Implemented ReadMutiLineInput() method to read multiple lines from console
- Improved user experience and enabled more complex interactions
      - Updated the ReadMutiLineInput method in Program.cs to use a StringBuilder instead of string concatenation for better performance.
      - Replaced the string concatenation with the AppendLine method to correctly handle multiline input.
      - Trimmed the trailing newline character from the input before returning.

      This commit fixes the issue with multiline input handling in SKonsole, ensuring that all lines are correctly captured and processed. The changes improve the performance and readability of the code.
🔧 Add Spectre.Console package

- Added Spectre.Console package with version 0.47.0 to the project dependencies.

✨ Add ConfigCommand to SKonsole

- Added a new ConfigCommand class to SKonsole, which handles skonsole configuration.
- The ConfigCommand class has two subcommands: "get" and "set".
- The "get" subcommand retrieves the value of a configuration key, while the "set" subcommand sets the value of a configuration key.
- The ConfigCommand class includes a RunConfigAsync method, which allows the user to interactively configure the skonsole by selecting a key and setting its value.
- The ConfigurationProvider class is updated to include a static Instance property, which provides a singleton instance of the ConfigurationProvider.
- The Program.cs file is updated to use the new ConfigCommand class and the ConfigurationProvider.Instance property.
- The skonsole configuration keys are hardcoded in the RunConfigAsync method, and the user is prompted to set the values for each key if they are not already set.
- The ConfigCommand class and the ConfigurationProvider class are added to the SKonsole.csproj file as project references.
      Trim whitespace from the config value before saving it to ensure consistent formatting.
Copy link
Owner

@lemillermicrosoft lemillermicrosoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Just a few questions for now. Otherwise LGTM. Will try and test it out soon.

apps/SKonsole/ConfigurationProvider.cs Show resolved Hide resolved
apps/SKonsole/Program.cs Outdated Show resolved Hide resolved
Copy link
Owner

@lemillermicrosoft lemillermicrosoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for contributing!

@lemillermicrosoft lemillermicrosoft merged commit a112bd1 into lemillermicrosoft:main Aug 15, 2023
lemillermicrosoft added a commit that referenced this pull request Aug 15, 2023
Implement the ConfigCommand class to manage configuration settings in
SKonsole. Add get and set commands for handling configuration keys and
values. Update ConfigurationProvider to read and write configuration data.
Replace the usage of environment variables with configuration variables
using the ConfigVar method. Update the error message to instruct users to
run `skonsole config` to set the configuration variable. Add a new method
ReadMutiLineInput to support multi-line user input in the console.

PR: #3

Co-authored-by: xbotter <xbotter@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants