Skip to content

feat: suggest sub commands#22

Merged
renancaraujo merged 11 commits intomainfrom
feat/suggest-sub-commands
Nov 25, 2022
Merged

feat: suggest sub commands#22
renancaraujo merged 11 commits intomainfrom
feat/suggest-sub-commands

Conversation

@renancaraujo
Copy link
Copy Markdown
Contributor

@renancaraujo renancaraujo commented Nov 23, 2022

Status

READY

Description

feat: suggest sub commands

closes #4

Cases covered:

example_cli|
   example_cli|
example_cli   |
example_cli some_command|
example_cli som|
   example_cli some_command|
example_cli some_command     |
example_cli -f --rootOption yay some_command|
example_cli alias|

Type of Change

  • ✨ New feature (non-breaking change which adds functionality)
  • 🛠️ Bug fix (non-breaking change which fixes an issue)
  • ❌ Breaking change (fix or feature that would cause existing functionality to change)
  • 🧹 Code refactor
  • ✅ Build configuration change
  • 📝 Documentation
  • 🗑️ Chore

@renancaraujo renancaraujo force-pushed the feat/suggest-sub-commands branch from f61eec3 to a8a73a9 Compare November 24, 2022 01:49
@renancaraujo renancaraujo marked this pull request as ready for review November 24, 2022 02:05
@renancaraujo renancaraujo force-pushed the feat/suggest-sub-commands branch from a8a73a9 to 13f0598 Compare November 24, 2022 02:08
@renancaraujo renancaraujo force-pushed the feat/suggest-sub-commands branch 4 times, most recently from 82d0404 to 536fb53 Compare November 24, 2022 11:30
@renancaraujo renancaraujo force-pushed the feat/suggest-sub-commands branch from 536fb53 to 2eb8c03 Compare November 24, 2022 11:44
@@ -516,7 +510,6 @@ void main() {
'basic usage with args in between',
forLine: 'example_cli some_other_command subcommand_alias',
suggests: allOptionsInThisLevel,
skip: notImplemmentedYet,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removing skip for cases we support now

/// - [AllOptionsAndCommandsCompletionResult]
/// - [MatchingCommandsCompletionResult]
@immutable
abstract class CompletionResult {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Refactored command results to have a more specific role, removing responsibilities form the parser, which did too much.

Comment on lines -57 to -69
case SystemShell.zsh:
// On zsh, colon acts as delimitation between a suggestion and its
// description. Any literal colon should be escaped.
final suggestion = entry.key.replaceAll(':', r'\:');
final description = entry.value?.replaceAll(':', r'\:');

logger.info(
'$suggestion${description != null ? ':$description' : ''}',
);
break;
case SystemShell.bash:
logger.info(entry.key);
break;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since we are not varying the "rendering" logic per "CompletionResult" subtype, this is now centralized in the runner and the completion result only contain completions.

argParser
..addOption(
'rootOption',
mandatory: true, // this should be disregarded
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Disregarded from the test? I am not sure I followed

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

from the parsing, since we clone options without rules

renancaraujo and others added 3 commits November 24, 2022 14:46
Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>
@renancaraujo renancaraujo force-pushed the feat/suggest-sub-commands branch from 8630b82 to a3b11f3 Compare November 24, 2022 14:49
Co-authored-by: Erick <erickzanardoo@gmail.com>
@renancaraujo renancaraujo force-pushed the feat/suggest-sub-commands branch from a3b11f3 to 0c9f361 Compare November 24, 2022 14:49
@renancaraujo renancaraujo merged commit ea3f5db into main Nov 25, 2022
@renancaraujo renancaraujo deleted the feat/suggest-sub-commands branch November 25, 2022 17:24
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.

feat: suggest sub commands at any level

4 participants