DEV Community

Yousef
Yousef

Posted on

Explore.CLI - Progress

Welcome back to the ongoing journey of enhancing Explore.CLI! As I discussed last week, my focus has been on implementing new features and refining existing ones. In this update, I am excited to share the progress made and the intricacies of the latest improvements.

Enhancing the 'Import' Feature

Building upon the momentum of previous weeks, where I enhanced the Export feature, I turned my attention to the Import feature. The primary enhancement was the integration of the --names option, similar to what was done for Export. This required a few key updates:

  • Modifying the Option variable names to indicate its dual functionality for both import and export.
  • Adjusting the importSpaceCommand to correctly utilize the names option.
  • Updating the ImportSpaces method to handle a comma-separated list of names.

The implementation ensures a more intuitive and flexible import process, catering to specific user needs.

Code Refinement and Bug Fixing

In addition to feature enhancement, a significant part of my focus was on refining existing code and addressing bugs:

  • Removing Deprecated Features: Following discussions on issue #18, I removed the import-inspector-collections feature, ensuring the codebase remains streamlined and up-to-date.
  • Bug Fixing: A small bug, identified in my previous contributions, was addressed. The application now displays an appropriate message when no matching spaces are found during export or import, improving user experience.

Code Snippets

Here's a glimpse of the key code changes implemented:

  1. Modifying the names option:
var names = new Option<string>(name: "--names", description: "The names of the spaces to export or import") { IsRequired = false };
Enter fullscreen mode Exit fullscreen mode
  1. Adjusting importSpaceCommand:
var importSpacesCommand = new Command("import-spaces")
{
    exploreCookie,
    importFilePath,
    names,
    verbose
};

importSpacesCommand.SetHandler(async (ec, fp, v, n) =>
    { await ImportSpaces(ec, fp, v, n); },
    exploreCookie,
    importFilePath,
    names,
    verbose);
Enter fullscreen mode Exit fullscreen mode
  1. Implementing checks for matching spaces during import and export:
// For Export
if (namesList?.Count > 0 && space.Name != null && !namesList.Contains(space.Name))
{
    AnsiConsole.MarkupLine($"[orange3]'Skipped {space.Name}': Name not found in list of names to export[/]");
    continue;
}
// For Import
    foreach (var exportedSpace in exportedSpaces.ExploreSpaces)
{
    if (namesList?.Count > 0 && exportedSpace.Name != null && !namesList.Contains(exportedSpace.Name)) {
    AnsiConsole.MarkupLine($"[orange3]'Skipped {exportedSpace.Name}': Name not found in list of names to import[/]");
    continue;
    }
}
Enter fullscreen mode Exit fullscreen mode

Documentation and Pull Request

Finally, the README.md file was meticulously updated to reflect these changes, aiding future contributors and users. All these updates are encapsulated in a pull request, which is currently under review. I have already addressed a minor typo pointed out by the repository owner and am eagerly awaiting the final approval.

Conclusion

This phase of enhancements to Explore.CLI has been a blend of expansion, refinement, and learning. It demonstrates the project's commitment to continuous improvement and user-centric development. As always, I am keen to hear feedback and look forward to sharing more updates soon.

Top comments (0)