
using namespace System.Management.Automation
using namespace System.Management.Automation.Language

Register-ArgumentCompleter -Native -CommandName 'bindgen' -ScriptBlock {
    param($wordToComplete, $commandAst, $cursorPosition)

    $commandElements = $commandAst.CommandElements
    $command = @(
        'bindgen'
        for ($i = 1; $i -lt $commandElements.Count; $i++) {
            $element = $commandElements[$i]
            if ($element -isnot [StringConstantExpressionAst] -or
                $element.StringConstantType -ne [StringConstantType]::BareWord -or
                $element.Value.StartsWith('-') -or
                $element.Value -eq $wordToComplete) {
                break
        }
        $element.Value
    }) -join ';'

    $completions = @(switch ($command) {
        'bindgen' {
            [CompletionResult]::new('--depfile', 'depfile', [CompletionResultType]::ParameterName, 'Path to write depfile to')
            [CompletionResult]::new('--default-enum-style', 'default-enum-style', [CompletionResultType]::ParameterName, 'The default STYLE of code used to generate enums')
            [CompletionResult]::new('--bitfield-enum', 'bitfield-enum', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a set of bitfield flags')
            [CompletionResult]::new('--newtype-enum', 'newtype-enum', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a newtype')
            [CompletionResult]::new('--newtype-global-enum', 'newtype-global-enum', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a global newtype')
            [CompletionResult]::new('--rustified-enum', 'rustified-enum', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a Rust enum')
            [CompletionResult]::new('--rustified-non-exhaustive-enum', 'rustified-non-exhaustive-enum', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a non-exhaustive Rust enum')
            [CompletionResult]::new('--constified-enum', 'constified-enum', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a series of constants')
            [CompletionResult]::new('--constified-enum-module', 'constified-enum-module', [CompletionResultType]::ParameterName, 'Mark any enum whose name matches REGEX as a module of constants')
            [CompletionResult]::new('--default-macro-constant-type', 'default-macro-constant-type', [CompletionResultType]::ParameterName, 'The default signed/unsigned TYPE for C macro constants')
            [CompletionResult]::new('--default-alias-style', 'default-alias-style', [CompletionResultType]::ParameterName, 'The default STYLE of code used to generate typedefs')
            [CompletionResult]::new('--normal-alias', 'normal-alias', [CompletionResultType]::ParameterName, 'Mark any typedef alias whose name matches REGEX to use normal type aliasing')
            [CompletionResult]::new('--new-type-alias', 'new-type-alias', [CompletionResultType]::ParameterName, 'Mark any typedef alias whose name matches REGEX to have a new type generated for it')
            [CompletionResult]::new('--new-type-alias-deref', 'new-type-alias-deref', [CompletionResultType]::ParameterName, 'Mark any typedef alias whose name matches REGEX to have a new type with Deref and DerefMut to the inner type')
            [CompletionResult]::new('--default-non-copy-union-style', 'default-non-copy-union-style', [CompletionResultType]::ParameterName, 'The default STYLE of code used to generate unions with non-Copy members. Note that ManuallyDrop was first stabilized in Rust 1.20.0')
            [CompletionResult]::new('--bindgen-wrapper-union', 'bindgen-wrapper-union', [CompletionResultType]::ParameterName, 'Mark any union whose name matches REGEX and who has a non-Copy member to use a bindgen-generated wrapper for fields')
            [CompletionResult]::new('--manually-drop-union', 'manually-drop-union', [CompletionResultType]::ParameterName, 'Mark any union whose name matches REGEX and who has a non-Copy member to use ManuallyDrop (stabilized in Rust 1.20.0) for fields')
            [CompletionResult]::new('--blocklist-type', 'blocklist-type', [CompletionResultType]::ParameterName, 'Mark TYPE as hidden')
            [CompletionResult]::new('--blocklist-function', 'blocklist-function', [CompletionResultType]::ParameterName, 'Mark FUNCTION as hidden')
            [CompletionResult]::new('--blocklist-item', 'blocklist-item', [CompletionResultType]::ParameterName, 'Mark ITEM as hidden')
            [CompletionResult]::new('--blocklist-file', 'blocklist-file', [CompletionResultType]::ParameterName, 'Mark FILE as hidden')
            [CompletionResult]::new('--blocklist-var', 'blocklist-var', [CompletionResultType]::ParameterName, 'Mark VAR as hidden')
            [CompletionResult]::new('--ctypes-prefix', 'ctypes-prefix', [CompletionResultType]::ParameterName, 'Use the given PREFIX before raw types instead of ::std::os::raw')
            [CompletionResult]::new('--anon-fields-prefix', 'anon-fields-prefix', [CompletionResultType]::ParameterName, 'Use the given PREFIX for anonymous fields')
            [CompletionResult]::new('--emit-ir-graphviz', 'emit-ir-graphviz', [CompletionResultType]::ParameterName, 'Dump a graphviz dot file to PATH')
            [CompletionResult]::new('--generate', 'generate', [CompletionResultType]::ParameterName, 'Generate only given items, split by commas. Valid values are `functions`,`types`, `vars`, `methods`, `constructors` and `destructors`')
            [CompletionResult]::new('--opaque-type', 'opaque-type', [CompletionResultType]::ParameterName, 'Mark TYPE as opaque')
            [CompletionResult]::new('-o', 'o', [CompletionResultType]::ParameterName, 'Write Rust bindings to OUTPUT')
            [CompletionResult]::new('--output', 'output', [CompletionResultType]::ParameterName, 'Write Rust bindings to OUTPUT')
            [CompletionResult]::new('--raw-line', 'raw-line', [CompletionResultType]::ParameterName, 'Add a raw line of Rust code at the beginning of output')
            [CompletionResult]::new('--module-raw-line', 'module-raw-line', [CompletionResultType]::ParameterName, 'Add a RAW_LINE of Rust code to a given module with name MODULE_NAME')
            [CompletionResult]::new('--rust-target', 'rust-target', [CompletionResultType]::ParameterName, 'Version of the Rust compiler to target. Any Rust version after 1.33.0 is supported. Defaults to 1.82.0.')
            [CompletionResult]::new('--rust-edition', 'rust-edition', [CompletionResultType]::ParameterName, 'Rust edition to target. Defaults to the latest edition supported by the chosen Rust target. Possible values: (2018|2021|2024). ')
            [CompletionResult]::new('--allowlist-function', 'allowlist-function', [CompletionResultType]::ParameterName, 'Allowlist all the free-standing functions matching REGEX. Other non-allowlisted functions will not be generated')
            [CompletionResult]::new('--allowlist-type', 'allowlist-type', [CompletionResultType]::ParameterName, 'Only generate types matching REGEX. Other non-allowlisted types will not be generated')
            [CompletionResult]::new('--allowlist-var', 'allowlist-var', [CompletionResultType]::ParameterName, 'Allowlist all the free-standing variables matching REGEX. Other non-allowlisted variables will not be generated')
            [CompletionResult]::new('--allowlist-file', 'allowlist-file', [CompletionResultType]::ParameterName, 'Allowlist all contents of PATH')
            [CompletionResult]::new('--allowlist-item', 'allowlist-item', [CompletionResultType]::ParameterName, 'Allowlist all items matching REGEX. Other non-allowlisted items will not be generated')
            [CompletionResult]::new('--formatter', 'formatter', [CompletionResultType]::ParameterName, 'Which FORMATTER should be used for the bindings')
            [CompletionResult]::new('--rustfmt-configuration-file', 'rustfmt-configuration-file', [CompletionResultType]::ParameterName, 'The absolute PATH to the rustfmt configuration file. The configuration file will be used for formatting the bindings. This parameter sets `formatter` to `rustfmt`')
            [CompletionResult]::new('--no-partialeq', 'no-partialeq', [CompletionResultType]::ParameterName, 'Avoid deriving PartialEq for types matching REGEX')
            [CompletionResult]::new('--no-copy', 'no-copy', [CompletionResultType]::ParameterName, 'Avoid deriving Copy and Clone for types matching REGEX')
            [CompletionResult]::new('--no-debug', 'no-debug', [CompletionResultType]::ParameterName, 'Avoid deriving Debug for types matching REGEX')
            [CompletionResult]::new('--no-default', 'no-default', [CompletionResultType]::ParameterName, 'Avoid deriving/implementing Default for types matching REGEX')
            [CompletionResult]::new('--no-hash', 'no-hash', [CompletionResultType]::ParameterName, 'Avoid deriving Hash for types matching REGEX')
            [CompletionResult]::new('--must-use-type', 'must-use-type', [CompletionResultType]::ParameterName, 'Add `#[must_use]` annotation to types matching REGEX')
            [CompletionResult]::new('--wasm-import-module-name', 'wasm-import-module-name', [CompletionResultType]::ParameterName, 'The NAME to be used in a #[link(wasm_import_module = ...)] statement')
            [CompletionResult]::new('--dynamic-loading', 'dynamic-loading', [CompletionResultType]::ParameterName, 'Use dynamic loading mode with the given library NAME')
            [CompletionResult]::new('--prefix-link-name', 'prefix-link-name', [CompletionResultType]::ParameterName, 'Prefix the name of exported symbols')
            [CompletionResult]::new('--override-abi', 'override-abi', [CompletionResultType]::ParameterName, 'Overrides the ABI of functions matching REGEX. The OVERRIDE value must be of the shape REGEX=ABI where ABI can be one of C, stdcall, efiapi, fastcall, thiscall, aapcs, win64 or C-unwind<.>')
            [CompletionResult]::new('--clang-macro-fallback-build-dir', 'clang-macro-fallback-build-dir', [CompletionResultType]::ParameterName, 'Set path for temporary files generated by fallback for clang macro parsing')
            [CompletionResult]::new('--with-derive-custom', 'with-derive-custom', [CompletionResultType]::ParameterName, 'Derive custom traits on any kind of type. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a coma-separated list of derive macros')
            [CompletionResult]::new('--with-derive-custom-struct', 'with-derive-custom-struct', [CompletionResultType]::ParameterName, 'Derive custom traits on a `struct`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a coma-separated list of derive macros')
            [CompletionResult]::new('--with-derive-custom-enum', 'with-derive-custom-enum', [CompletionResultType]::ParameterName, 'Derive custom traits on an `enum`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a coma-separated list of derive macros')
            [CompletionResult]::new('--with-derive-custom-union', 'with-derive-custom-union', [CompletionResultType]::ParameterName, 'Derive custom traits on a `union`. The CUSTOM value must be of the shape REGEX=DERIVE where DERIVE is a coma-separated list of derive macros')
            [CompletionResult]::new('--with-attribute-custom', 'with-attribute-custom', [CompletionResultType]::ParameterName, 'Add custom attributes on any kind of type. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes')
            [CompletionResult]::new('--with-attribute-custom-struct', 'with-attribute-custom-struct', [CompletionResultType]::ParameterName, 'Add custom attributes on a `struct`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes')
            [CompletionResult]::new('--with-attribute-custom-enum', 'with-attribute-custom-enum', [CompletionResultType]::ParameterName, 'Add custom attributes on an `enum`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes')
            [CompletionResult]::new('--with-attribute-custom-union', 'with-attribute-custom-union', [CompletionResultType]::ParameterName, 'Add custom attributes on a `union`. The CUSTOM value must be of the shape REGEX=ATTRIBUTE where ATTRIBUTE is a coma-separated list of attributes')
            [CompletionResult]::new('--wrap-static-fns-path', 'wrap-static-fns-path', [CompletionResultType]::ParameterName, 'Sets the PATH for the source file that must be created due to the presence of `static` and `static inline` functions')
            [CompletionResult]::new('--wrap-static-fns-suffix', 'wrap-static-fns-suffix', [CompletionResultType]::ParameterName, 'Sets the SUFFIX added to the extern wrapper functions generated for `static` and `static inline` functions')
            [CompletionResult]::new('--default-visibility', 'default-visibility', [CompletionResultType]::ParameterName, 'Set the default VISIBILITY of fields, including bitfields and accessor methods for bitfields. This flag is ignored if the `--respect-cxx-access-specs` flag is used')
            [CompletionResult]::new('--generate-shell-completions', 'generate-shell-completions', [CompletionResultType]::ParameterName, 'Generates completions for the specified SHELL, sends them to `stdout` and exits')
            [CompletionResult]::new('--no-layout-tests', 'no-layout-tests', [CompletionResultType]::ParameterName, 'Avoid generating layout tests for any type')
            [CompletionResult]::new('--no-derive-copy', 'no-derive-copy', [CompletionResultType]::ParameterName, 'Avoid deriving Copy on any type')
            [CompletionResult]::new('--no-derive-debug', 'no-derive-debug', [CompletionResultType]::ParameterName, 'Avoid deriving Debug on any type')
            [CompletionResult]::new('--no-derive-default', 'no-derive-default', [CompletionResultType]::ParameterName, 'Avoid deriving Default on any type')
            [CompletionResult]::new('--impl-debug', 'impl-debug', [CompletionResultType]::ParameterName, 'Create a Debug implementation if it cannot be derived automatically')
            [CompletionResult]::new('--impl-partialeq', 'impl-partialeq', [CompletionResultType]::ParameterName, 'Create a PartialEq implementation if it cannot be derived automatically')
            [CompletionResult]::new('--with-derive-default', 'with-derive-default', [CompletionResultType]::ParameterName, 'Derive Default on any type')
            [CompletionResult]::new('--with-derive-hash', 'with-derive-hash', [CompletionResultType]::ParameterName, 'Derive Hash on any type')
            [CompletionResult]::new('--with-derive-partialeq', 'with-derive-partialeq', [CompletionResultType]::ParameterName, 'Derive PartialEq on any type')
            [CompletionResult]::new('--with-derive-partialord', 'with-derive-partialord', [CompletionResultType]::ParameterName, 'Derive PartialOrd on any type')
            [CompletionResult]::new('--with-derive-eq', 'with-derive-eq', [CompletionResultType]::ParameterName, 'Derive Eq on any type')
            [CompletionResult]::new('--with-derive-ord', 'with-derive-ord', [CompletionResultType]::ParameterName, 'Derive Ord on any type')
            [CompletionResult]::new('--no-doc-comments', 'no-doc-comments', [CompletionResultType]::ParameterName, 'Avoid including doc comments in the output, see: <https://github.com/rust-lang/rust-bindgen/issues/426>')
            [CompletionResult]::new('--no-recursive-allowlist', 'no-recursive-allowlist', [CompletionResultType]::ParameterName, 'Disable allowlisting types recursively. This will cause bindgen to emit Rust code that won''t compile! See the `bindgen::Builder::allowlist_recursively` method''s documentation for details')
            [CompletionResult]::new('--objc-extern-crate', 'objc-extern-crate', [CompletionResultType]::ParameterName, 'Use extern crate instead of use for objc')
            [CompletionResult]::new('--generate-block', 'generate-block', [CompletionResultType]::ParameterName, 'Generate block signatures instead of void pointers')
            [CompletionResult]::new('--generate-cstr', 'generate-cstr', [CompletionResultType]::ParameterName, 'Generate string constants as `&CStr` instead of `&[u8]`')
            [CompletionResult]::new('--block-extern-crate', 'block-extern-crate', [CompletionResultType]::ParameterName, 'Use extern crate instead of use for block')
            [CompletionResult]::new('--distrust-clang-mangling', 'distrust-clang-mangling', [CompletionResultType]::ParameterName, 'Do not trust the libclang-provided mangling')
            [CompletionResult]::new('--builtins', 'builtins', [CompletionResultType]::ParameterName, 'Output bindings for builtin definitions, e.g. __builtin_va_list')
            [CompletionResult]::new('--time-phases', 'time-phases', [CompletionResultType]::ParameterName, 'Time the different bindgen phases and print to stderr')
            [CompletionResult]::new('--emit-clang-ast', 'emit-clang-ast', [CompletionResultType]::ParameterName, 'Output the Clang AST for debugging purposes')
            [CompletionResult]::new('--emit-ir', 'emit-ir', [CompletionResultType]::ParameterName, 'Output our internal IR for debugging purposes')
            [CompletionResult]::new('--enable-cxx-namespaces', 'enable-cxx-namespaces', [CompletionResultType]::ParameterName, 'Enable support for C++ namespaces')
            [CompletionResult]::new('--disable-name-namespacing', 'disable-name-namespacing', [CompletionResultType]::ParameterName, 'Disable namespacing via mangling, causing bindgen to generate names like `Baz` instead of `foo_bar_Baz` for an input name `foo::bar::Baz`')
            [CompletionResult]::new('--disable-nested-struct-naming', 'disable-nested-struct-naming', [CompletionResultType]::ParameterName, 'Disable nested struct naming, causing bindgen to generate names like `bar` instead of `foo_bar` for a nested definition `struct foo { struct bar { } b; };`')
            [CompletionResult]::new('--disable-untagged-union', 'disable-untagged-union', [CompletionResultType]::ParameterName, 'Disable support for native Rust unions')
            [CompletionResult]::new('--disable-header-comment', 'disable-header-comment', [CompletionResultType]::ParameterName, 'Suppress insertion of bindgen''s version identifier into generated bindings')
            [CompletionResult]::new('--ignore-functions', 'ignore-functions', [CompletionResultType]::ParameterName, 'Do not generate bindings for functions or methods. This is useful when you only care about struct layouts')
            [CompletionResult]::new('--ignore-methods', 'ignore-methods', [CompletionResultType]::ParameterName, 'Do not generate bindings for methods')
            [CompletionResult]::new('--no-convert-floats', 'no-convert-floats', [CompletionResultType]::ParameterName, 'Do not automatically convert floats to f32/f64')
            [CompletionResult]::new('--no-prepend-enum-name', 'no-prepend-enum-name', [CompletionResultType]::ParameterName, 'Do not prepend the enum name to constant or newtype variants')
            [CompletionResult]::new('--no-include-path-detection', 'no-include-path-detection', [CompletionResultType]::ParameterName, 'Do not try to detect default include paths')
            [CompletionResult]::new('--fit-macro-constant-types', 'fit-macro-constant-types', [CompletionResultType]::ParameterName, 'Try to fit macro constants into types smaller than u32/i32')
            [CompletionResult]::new('--use-core', 'use-core', [CompletionResultType]::ParameterName, 'Use types from Rust core instead of std')
            [CompletionResult]::new('--conservative-inline-namespaces', 'conservative-inline-namespaces', [CompletionResultType]::ParameterName, 'Conservatively generate inline namespaces to avoid name conflicts')
            [CompletionResult]::new('--generate-inline-functions', 'generate-inline-functions', [CompletionResultType]::ParameterName, 'Generate inline functions')
            [CompletionResult]::new('--verbose', 'verbose', [CompletionResultType]::ParameterName, 'Print verbose error messages')
            [CompletionResult]::new('--dump-preprocessed-input', 'dump-preprocessed-input', [CompletionResultType]::ParameterName, 'Preprocess and dump the input header files to disk. Useful when debugging bindgen, using C-Reduce, or when filing issues. The resulting file will be named something like `__bindgen.i` or `__bindgen.ii`')
            [CompletionResult]::new('--no-record-matches', 'no-record-matches', [CompletionResultType]::ParameterName, 'Do not record matching items in the regex sets. This disables reporting of unused items')
            [CompletionResult]::new('--no-size_t-is-usize', 'no-size_t-is-usize', [CompletionResultType]::ParameterName, 'Do not bind size_t as usize (useful on platforms where those types are incompatible)')
            [CompletionResult]::new('--no-rustfmt-bindings', 'no-rustfmt-bindings', [CompletionResultType]::ParameterName, 'Do not format the generated bindings with rustfmt. This option is deprecated, please use `--formatter=none` instead')
            [CompletionResult]::new('--enable-function-attribute-detection', 'enable-function-attribute-detection', [CompletionResultType]::ParameterName, 'Enables detecting unexposed attributes in functions (slow). Used to generate `#[must_use]` annotations')
            [CompletionResult]::new('--use-array-pointers-in-arguments', 'use-array-pointers-in-arguments', [CompletionResultType]::ParameterName, 'Use `*const [T; size]` instead of `*const T` for C arrays')
            [CompletionResult]::new('--dynamic-link-require-all', 'dynamic-link-require-all', [CompletionResultType]::ParameterName, 'Require successful linkage to all functions in the library')
            [CompletionResult]::new('--respect-cxx-access-specs', 'respect-cxx-access-specs', [CompletionResultType]::ParameterName, 'Makes generated bindings `pub` only for items if the items are publicly accessible in C++')
            [CompletionResult]::new('--translate-enum-integer-types', 'translate-enum-integer-types', [CompletionResultType]::ParameterName, 'Always translate enum integer types to native Rust integer types')
            [CompletionResult]::new('--c-naming', 'c-naming', [CompletionResultType]::ParameterName, 'Generate types with C style naming')
            [CompletionResult]::new('--explicit-padding', 'explicit-padding', [CompletionResultType]::ParameterName, 'Always output explicit padding fields')
            [CompletionResult]::new('--use-specific-virtual-function-receiver', 'use-specific-virtual-function-receiver', [CompletionResultType]::ParameterName, 'Always be specific about the ''receiver'' of a virtual function')
            [CompletionResult]::new('--use-distinct-char16-t', 'use-distinct-char16-t', [CompletionResultType]::ParameterName, 'Use distinct char16_t')
            [CompletionResult]::new('--represent-cxx-operators', 'represent-cxx-operators', [CompletionResultType]::ParameterName, 'Output C++ overloaded operators')
            [CompletionResult]::new('--vtable-generation', 'vtable-generation', [CompletionResultType]::ParameterName, 'Enables generation of vtable functions')
            [CompletionResult]::new('--sort-semantically', 'sort-semantically', [CompletionResultType]::ParameterName, 'Enables sorting of code generation in a predefined manner')
            [CompletionResult]::new('--merge-extern-blocks', 'merge-extern-blocks', [CompletionResultType]::ParameterName, 'Deduplicates extern blocks')
            [CompletionResult]::new('--wrap-unsafe-ops', 'wrap-unsafe-ops', [CompletionResultType]::ParameterName, 'Wrap unsafe operations in unsafe blocks')
            [CompletionResult]::new('--clang-macro-fallback', 'clang-macro-fallback', [CompletionResultType]::ParameterName, 'Enable fallback for clang macro parsing')
            [CompletionResult]::new('--flexarray-dst', 'flexarray-dst', [CompletionResultType]::ParameterName, 'Use DSTs to represent structures with flexible array members')
            [CompletionResult]::new('--wrap-static-fns', 'wrap-static-fns', [CompletionResultType]::ParameterName, 'Generate wrappers for `static` and `static inline` functions')
            [CompletionResult]::new('--generate-deleted-functions', 'generate-deleted-functions', [CompletionResultType]::ParameterName, 'Whether to generate C++ functions marked with "=delete" even though they can''t be called')
            [CompletionResult]::new('--generate-pure-virtual-functions', 'generate-pure-virtual-functions', [CompletionResultType]::ParameterName, 'Whether to generate C++ "pure virtual" functions even though they can''t be called')
            [CompletionResult]::new('--generate-private-functions', 'generate-private-functions', [CompletionResultType]::ParameterName, 'Whether to generate C++ private functions even though they can''t be called')
            [CompletionResult]::new('--emit-diagnostics', 'emit-diagnostics', [CompletionResultType]::ParameterName, 'Whether to emit diagnostics or not')
            [CompletionResult]::new('--experimental', 'experimental', [CompletionResultType]::ParameterName, 'Enables experimental features')
            [CompletionResult]::new('-V', 'V', [CompletionResultType]::ParameterName, 'Prints the version, and exits')
            [CompletionResult]::new('--version', 'version', [CompletionResultType]::ParameterName, 'Prints the version, and exits')
            [CompletionResult]::new('-h', 'h', [CompletionResultType]::ParameterName, 'Print help')
            [CompletionResult]::new('--help', 'help', [CompletionResultType]::ParameterName, 'Print help')
            break
        }
    })

    $completions.Where{ $_.CompletionText -like "$wordToComplete*" } |
        Sort-Object -Property ListItemText
}
