* add implementation of replacing(_:with:)
* remove use of range(of:)
* Consolidate foundation usage
* Consolidate error to string logic
* Clean up env a bit
* Adopt upcoming Swift language feature MemberImportVisibility.
Enable the language feature flag for SE-0444. This instructs the compiler to
be stricter about requiring import declarations in order to access member
declarations.
* Replace `#if swift(>=6.0)` guards with `#if compiler(>=6.0)`.
All uses of `internal import` were previously guarded with `#if swift(>=6.0)`,
presumably to handle differences in compiler support for `internal import`.
However, `#if swift(>=)` is not the correct directive to use for this purpose,
as it primarily tests the language mode that is enabled. These existing
conditionals never evaluated true when building this package since it is not
configured to build with Swift 6 enabled. Instead, use `#if compiler(>=6.0)`
which correctly predicates the imports on only the compiler version.
* Do not indent zsh cases.
Simplify zsh indent generation.
* Do not prefix zsh cases with an open parenthesis.
* Prevent zsh parameter word splitting.
Brace & quote parameter uses.
Use [@] for quoted array output.
* Improve comment in ZshCompletionsGenerator.swift.
* Fix incorrect zsh shellCommand single quotes:
4 consecutive single quotes were obviously intended to be 2 escaped single quotes,
but that isn't zsh syntax.
Use 2 double quotes instead.
* Remove extraneous zsh newline.
* Improve zsh variable declarations: scoping, typing & readonly.
Remove trailing spaces from InstallingCompletionScripts.md.
* Include zsh words before current subcommand in custom completion arg.
* Make subcommandHandler in ZshCompletionsGenerator.swift immutable.
* Escape zsh single quotes via '\'' instead of via '"'"'.
* Escape single quotes in zsh shellCommand String.
If someone already escapes single quotes from the String, this will cause an issue,
but no one should be required to go to the trouble to manually escape single quotes
in their script, especially since the requirement isn't documented or normal.
* Fix zsh custom completions for empty [String] & String elements.
If a Swift custom completion function returns an empty [String], if the user tries to
complete it, refuse to complete instead of inserting a blank space into the command line.
If a Swift custom completion function returns a [String] including a Swift empty String
or including a String with a description but with a blank completion
(e.g., ":description"), if that completion is selected, complete to a zsh empty string
'' instead of inserting a blank space into the command line.
Disambiguating between an empty [String] & a [String] with one empty String element
requires that an extra value be appended to the output of the Swift custom function,
which is then removed by the completion script.
* Simplify zsh subcommand completion function dispatch.
* Restrict access to symbols in ZshCompletionsGenerator.swift.
* Add default help to zsh completions iff no existing help subcommand.
* Use interpolated Strings in ZshCompletionsGenerator.swift.
* Create & use zsh __completion function.
* Improve zsh escaping.
* Set zsh settings to a known state.
Disable history ! in zsh completion scripts.
* Inline single-use functions & variables in ZshCompletionsGenerator.swift.
* Overhaul ZshCompletionsGenerator.swift as [ParsableCommand.Type] extension.
* Move functions in ZshCompletionsGenerator.swift.
Move from ArgumentDefinition extension to [ParsableCommand.Type] extension.
* Move zsh helper functions before command functions to mirror other shells.
* Prefix zsh helper functions with command name to prevent naming clashes.
Function names are globally scoped.
Without namespacing, if 2 programs use different versions of Swift Argument Parser,
one could overwrite the other's different version of the same helper function.
Renamed functions from *_completion to *_complete, as they complete, not return a
completion.
* Separate zsh _arguments flags from specs using :.
* Rename zsh args variable as arg_specs.
* Simplify zshCompletionString(…).
* Allow generating zsh setup scripts for arguments.
* Use zsh array for list completions instead of nested strings.
Allows list completions to contain spaces.
Resolve#726
* Make CompletionShell.format(…) internal instead of public.
* Reword uses of "iff" in completions code.
Redid a comment as a DocC.
* Replace zsh END_MARKER pseudo-completion with a space to ease migration.
Document why & how this pseudo-completion is used.
Do not trim whitespace in testing, as that breaks with the space pseudo-completion.
Testing should be as exact as possible; trimming whitespace makes it less exact.
* Throw error if attempting to generate a zsh completion script for no commands.
Force unwrap first in ZshCompletionsGenerator.swift.
---------
Signed-off-by: Ross Goldberg <484615+rgoldberg@users.noreply.github.com>
* Respect the `COLUMNS` and `LINES` environment variables, if set, when determining screen size.
* Add test for COLUMNS environment override
* Make columns test idempotent against there being a COLUMNS value already set in the environment
* Make help tests be more explicit about screen widths.
Adds a new `AsyncParsableCommand` protocol, which provides a
`static func main() async` entry point and can call through to the root
command's or a subcommand's asynchronous `run()` method. For this
asynchronous execution, the root command must conform to `AsyncParsableCommand`,
but its subcommands can be a mix of asynchronous and synchronous commands.
Due to an issue in Swift 5.5, you can only use `@main` on an
`AsyncParsableCommand` root command starting in Swift 5.6.
This change also includes a workaround for clients that are using Swift 5.5.
Declare a separate type that conforms to `AsyncMainProtocol` and add the `@main`
attribute to that type.
```
@main enum Main: AsyncMain {
typealias Command = <#command#>
}
```
* Add 'see help' messages to usage messages and the help screen
* Update tests for new help messages.
* Update guide examples with additional help messages
* Add an API for converting an error to an exit code
* Make ExitCode more useful as a value type
* Update tests to use ExitCode values
* Typo fix
* Add a test for ExitCode.isSuccess
* Switch to just using ExitCode for tests