Skip to content

Commit e249a97

Browse files
committed
refactor: renamed executablName to rootCommand
1 parent 55ee7ec commit e249a97

2 files changed

Lines changed: 44 additions & 45 deletions

File tree

lib/src/installer/completion_installation.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,14 @@ ${configuration!.sourceLineTemplate(scriptPath)}''';
305305
logger.info('Added config to $configFilePath');
306306
}
307307

308-
/// Uninstalls the completion for the command [executableName] on the current
308+
/// Uninstalls the completion for the command [rootCommand] on the current
309309
/// shell.
310310
///
311311
/// Before uninstalling, it checks if the completion is installed:
312312
/// - The shell has an existing RCFile with a completion
313313
/// [ScriptConfigurationEntry].
314314
/// - The shell has an exisiting completion configuration file with a
315-
/// [ScriptConfigurationEntry] for the [executableName].
315+
/// [ScriptConfigurationEntry] for the [rootCommand].
316316
///
317317
/// If any of the above is not true, it throws a
318318
/// [CompletionUnistallationException].
@@ -324,24 +324,24 @@ ${configuration!.sourceLineTemplate(scriptPath)}''';
324324
/// file. In the case that there are no other completion scripts installed on
325325
/// other shells the completion config directory is deleted, leaving the
326326
/// user's system as it was before the installation.
327-
void uninstall(String executableName) {
327+
void uninstall(String rootCommand) {
328328
final configuration = this.configuration!;
329329
logger.detail(
330-
'''Uninstalling completion for the command $executableName on ${configuration.shell.name}''',
330+
'''Uninstalling completion for the command $rootCommand on ${configuration.shell.name}''',
331331
);
332332

333333
final shellRCFile = File(_shellRCFilePath);
334334
if (!shellRCFile.existsSync()) {
335335
throw CompletionUnistallationException(
336-
executableName: executableName,
336+
executableName: rootCommand,
337337
message: 'No shell RC file found at ${shellRCFile.path}',
338338
);
339339
}
340340

341341
const completionEntry = ScriptConfigurationEntry('Completion');
342342
if (!completionEntry.existsIn(shellRCFile)) {
343343
throw CompletionUnistallationException(
344-
executableName: executableName,
344+
executableName: rootCommand,
345345
message: 'Completion is not installed at ${shellRCFile.path}',
346346
);
347347
}
@@ -352,10 +352,10 @@ ${configuration!.sourceLineTemplate(scriptPath)}''';
352352
configuration.completionConfigForShellFileName,
353353
),
354354
);
355-
final executableEntry = ScriptConfigurationEntry(executableName);
355+
final executableEntry = ScriptConfigurationEntry(rootCommand);
356356
if (!executableEntry.existsIn(shellCompletionConfigurationFile)) {
357357
throw CompletionUnistallationException(
358-
executableName: executableName,
358+
executableName: rootCommand,
359359
message:
360360
'''No shell script file found at ${shellCompletionConfigurationFile.path}''',
361361
);
@@ -364,7 +364,7 @@ ${configuration!.sourceLineTemplate(scriptPath)}''';
364364
final executableShellCompletionScriptFile = File(
365365
path.join(
366366
completionConfigDir.path,
367-
'$executableName.${configuration.shell.name}',
367+
'$rootCommand.${configuration.shell.name}',
368368
),
369369
);
370370
if (executableShellCompletionScriptFile.existsSync()) {

test/src/installer/completion_installation_test.dart

Lines changed: 35 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void main() {
496496

497497
group('uninstall', () {
498498
test(
499-
'''deletes entire completion configuration when there is a single executable''',
499+
'''deletes entire completion configuration when there is a single command''',
500500
() {
501501
final tempDirectory = Directory.systemTemp.createTempSync();
502502
addTearDown(() => tempDirectory.deleteSync(recursive: true));
@@ -505,7 +505,7 @@ void main() {
505505
final rcFile = File(path.join(tempDirectory.path, '.zshrc'))
506506
..createSync();
507507

508-
const executableName = 'very_good';
508+
const rootCommand = 'very_good';
509509
final installation = CompletionInstallation(
510510
logger: logger,
511511
isWindows: false,
@@ -514,8 +514,8 @@ void main() {
514514
},
515515
configuration: configuration,
516516
)
517-
..install(executableName)
518-
..uninstall(executableName);
517+
..install(rootCommand)
518+
..uninstall(rootCommand);
519519

520520
expect(
521521
rcFile.existsSync(),
@@ -531,7 +531,7 @@ void main() {
531531
});
532532

533533
test(
534-
'''only deletes shell configuration when there is a single executable in multiple shells''',
534+
'''only deletes shell configuration when there is a single command in multiple shells''',
535535
() {
536536
final tempDirectory = Directory.systemTemp.createTempSync();
537537
addTearDown(() => tempDirectory.deleteSync(recursive: true));
@@ -544,7 +544,7 @@ void main() {
544544
final bashRCFile = File(path.join(tempDirectory.path, '.bash_profile'))
545545
..createSync();
546546

547-
const executableName = 'very_good';
547+
const rootCommand = 'very_good';
548548

549549
final bashInstallation = CompletionInstallation(
550550
logger: logger,
@@ -553,7 +553,7 @@ void main() {
553553
'HOME': tempDirectory.path,
554554
},
555555
configuration: bashConfig,
556-
)..install(executableName);
556+
)..install(rootCommand);
557557

558558
final zshInstallation = CompletionInstallation(
559559
logger: logger,
@@ -563,8 +563,8 @@ void main() {
563563
},
564564
configuration: zshConfig,
565565
)
566-
..install(executableName)
567-
..uninstall(executableName);
566+
..install(rootCommand)
567+
..uninstall(rootCommand);
568568

569569
// Zsh should be uninstalled
570570
expect(
@@ -590,16 +590,16 @@ void main() {
590590
reason: 'Zsh completion configuration should be deleted.',
591591
);
592592

593-
final zshExecutableCompletionConfigurationFile = File(
593+
final zshCommandCompletionConfigurationFile = File(
594594
path.join(
595595
zshInstallation.completionConfigDir.path,
596-
'$executableName.zsh',
596+
'$rootCommand.zsh',
597597
),
598598
);
599599
expect(
600-
zshExecutableCompletionConfigurationFile.existsSync(),
600+
zshCommandCompletionConfigurationFile.existsSync(),
601601
isFalse,
602-
reason: 'Zsh executable completion configuration should be deleted.',
602+
reason: 'Zsh command completion configuration should be deleted.',
603603
);
604604

605605
// Bash should still be installed
@@ -626,17 +626,16 @@ void main() {
626626
reason: 'Bash completion configuration should still exist.',
627627
);
628628

629-
final bashExecutableCompletionConfigurationFile = File(
629+
final bashCommandCompletionConfigurationFile = File(
630630
path.join(
631631
bashInstallation.completionConfigDir.path,
632-
'$executableName.bash',
632+
'$rootCommand.bash',
633633
),
634634
);
635635
expect(
636-
bashExecutableCompletionConfigurationFile.existsSync(),
636+
bashCommandCompletionConfigurationFile.existsSync(),
637637
isTrue,
638-
reason:
639-
'Bash executable completion configuration should still exist.',
638+
reason: 'Bash command completion configuration should still exist.',
640639
);
641640

642641
expect(
@@ -647,14 +646,14 @@ void main() {
647646
});
648647

649648
test(
650-
'''only deletes executable completion configuration when there are multiple installed executables''',
649+
'''only deletes command completion configuration when there are multiple installed commands''',
651650
() {
652651
final tempDirectory = Directory.systemTemp.createTempSync();
653652
addTearDown(() => tempDirectory.deleteSync(recursive: true));
654653

655654
final configuration = zshConfiguration;
656-
const executableName = 'very_good';
657-
const anotherExecutableName = 'not_good';
655+
const commandName = 'very_good';
656+
const anotherCommandName = 'not_good';
658657

659658
final rcFile = File(path.join(tempDirectory.path, '.zshrc'))
660659
..createSync();
@@ -666,8 +665,8 @@ void main() {
666665
},
667666
configuration: configuration,
668667
)
669-
..install(executableName)
670-
..install(anotherExecutableName);
668+
..install(commandName)
669+
..install(anotherCommandName);
671670

672671
final shellCompletionConfigurationFile = File(
673672
path.join(
@@ -676,7 +675,7 @@ void main() {
676675
),
677676
);
678677

679-
installation.uninstall(executableName);
678+
installation.uninstall(commandName);
680679

681680
expect(
682681
rcFile.existsSync(),
@@ -696,43 +695,43 @@ void main() {
696695
);
697696

698697
expect(
699-
const ScriptConfigurationEntry(executableName)
698+
const ScriptConfigurationEntry(commandName)
700699
.existsIn(shellCompletionConfigurationFile),
701700
isFalse,
702701
reason:
703-
'''Executable completion for $executableName configuration should be removed.''',
702+
'''Command completion for $commandName configuration should be removed.''',
704703
);
705-
final executableCompletionConfigurationFile = File(
704+
final commandCompletionConfigurationFile = File(
706705
path.join(
707706
installation.completionConfigDir.path,
708-
'$executableName.zsh',
707+
'$commandName.zsh',
709708
),
710709
);
711710
expect(
712-
executableCompletionConfigurationFile.existsSync(),
711+
commandCompletionConfigurationFile.existsSync(),
713712
false,
714713
reason:
715-
'''Executable completion configuration for $executableName should be deleted.''',
714+
'''Command completion configuration for $commandName should be deleted.''',
716715
);
717716

718717
expect(
719-
const ScriptConfigurationEntry(anotherExecutableName)
718+
const ScriptConfigurationEntry(anotherCommandName)
720719
.existsIn(shellCompletionConfigurationFile),
721720
isTrue,
722721
reason:
723-
'''Executable completion configuration for $anotherExecutableName should still exist.''',
722+
'''Command completion configuration for $anotherCommandName should still exist.''',
724723
);
725-
final anotherExecutableCompletionConfigurationFile = File(
724+
final anotherCommandCompletionConfigurationFile = File(
726725
path.join(
727726
installation.completionConfigDir.path,
728-
'$anotherExecutableName.zsh',
727+
'$anotherCommandName.zsh',
729728
),
730729
);
731730
expect(
732-
anotherExecutableCompletionConfigurationFile.existsSync(),
731+
anotherCommandCompletionConfigurationFile.existsSync(),
733732
isTrue,
734733
reason:
735-
'''Executable completion configuration for $anotherExecutableName should still exist.''',
734+
'''Command completion configuration for $anotherCommandName should still exist.''',
736735
);
737736
});
738737

0 commit comments

Comments
 (0)