Skip to content

Commit

Permalink
Merge pull request #715 from atsign-foundation/usage-line-length
Browse files Browse the repository at this point in the history
  • Loading branch information
gkc authored Jan 23, 2024
2 parents 2404c99 + cb8a401 commit faedf8c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ class SshnpArg {
bool withDefaults = true,
Iterable<String>? includeList,
Iterable<String>? excludeList,
int? usageLineLength,
}) {
var parser = ArgParser();
var parser = ArgParser(usageLineLength: usageLineLength);
// Basic arguments
for (SshnpArg arg in SshnpArg.args) {
if (!parserType.shouldParse(arg.parseWhen)) {
Expand Down
4 changes: 3 additions & 1 deletion packages/dart/sshnoports/bin/sshnp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ void main(List<String> args) async {
AtSignLogger.root_level = 'SHOUT';
AtSignLogger.defaultLoggingHandler = AtSignLogger.stdErrLoggingHandler;

ExtendedArgParser parser = ExtendedArgParser();
ExtendedArgParser parser = ExtendedArgParser(
usageLineLength: stdout.hasTerminal ? stdout.terminalColumns : null,
);

// Create the printUsage closure
void printUsage({Object? error}) {
Expand Down
10 changes: 7 additions & 3 deletions packages/dart/sshnoports/lib/src/extended_arg_parser.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ const legacyDaemonFlag = 'legacy-daemon';
const outputExecutionCommandFlag = 'output-execution-command';

class ExtendedArgParser {
static ArgParser createArgParser() {
final parser = SshnpArg.createArgParser(parserType: ParserType.commandLine);
static ArgParser createArgParser({int? usageLineLength}) {
final parser = SshnpArg.createArgParser(
parserType: ParserType.commandLine,
usageLineLength: usageLineLength,
);

parser.addOption(
sshClientOption,
Expand Down Expand Up @@ -45,7 +48,8 @@ class ExtendedArgParser {
final ArgParser parser;
ArgResults? results;

ExtendedArgParser() : parser = createArgParser();
ExtendedArgParser({int? usageLineLength})
: parser = createArgParser(usageLineLength: usageLineLength);

ArgResults parse(Iterable<String> args) {
return results = parser.parse(args);
Expand Down

0 comments on commit faedf8c

Please sign in to comment.