Skip to content

[args] Bug: inconsistent newline behavior after Separator Name #917

@indraneel12

Description

@indraneel12

Consider the following code (can be run in DartPad):

import 'package:args/command_runner.dart' show CommandRunner;

void main() {
  final runner = CommandRunner(
    'mock-command',
    'Mock Command to explain a newline bug in this Package.',
  );
  runner.argParser.addFlag(
    'flag-0',
    help: 'No newline problem after Separator Name when this section exists.',
  );
  runner.argParser.addSeparator('Group 1 (OK)');
  runner.argParser.addFlag('flag-1');
  runner.argParser.addFlag('flag-2');
  runner.argParser.addFlag('flag-3');
  runner.argParser.addSeparator('Group 2 (newline problem)');
  runner.argParser.addFlag('flag-4');
  runner.argParser.addFlag('flag-5', help: 'This section does not work here.');
  runner.argParser.addFlag('flag-6');
  runner.argParser.addSeparator('Group 3 (newline problem)');
  runner.argParser.addFlag('flag-7');
  runner.argParser.addFlag('flag-8');
  runner.argParser.addFlag('flag-9', help: 'This section works at group-end.');
  runner.argParser.addSeparator('Group 4 (OK)');
  runner.argParser.addFlag('flag-10');
  runner.argParser.addFlag('flag-11');
  runner.argParser.addSeparator('Group 5 (newline problem)');
  runner.argParser.addFlag('flag-12');
  print(runner.usage);
}

The output of my Minimal Reproducible Example is self-explanatory:

Mock Command to explain a newline bug in this Package.

Usage: mock-command <command> [arguments]

Global options:
-h, --help            Print this usage information.
    --[no-]flag-0     No newline problem after Separator Name when this section exists.

Group 1 (OK)
    --[no-]flag-1     
    --[no-]flag-2     
    --[no-]flag-3     

Group 2 (newline problem)

    --[no-]flag-4     
    --[no-]flag-5     This section does not work here.
    --[no-]flag-6     

Group 3 (newline problem)

    --[no-]flag-7     
    --[no-]flag-8     
    --[no-]flag-9     This section works at group-end.

Group 4 (OK)
    --[no-]flag-10    
    --[no-]flag-11    

Group 5 (newline problem)

    --[no-]flag-12    

Available commands:
  help   Display help information for mock-command.

Run "mock-command help <command>" for more information about a command.

I was debugging my project, and I guess this problem originates within void _writeLine(int column, String text) from this Package.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions