Skip to content

cli: improve auto-completion code#21745

Open
matthiasstraka wants to merge 1 commit intoggml-org:masterfrom
matthiasstraka:cli-string-cleanup
Open

cli: improve auto-completion code#21745
matthiasstraka wants to merge 1 commit intoggml-org:masterfrom
matthiasstraka:cli-string-cleanup

Conversation

@matthiasstraka
Copy link
Copy Markdown

Overview

This PR cleans up the code for cli auto-completion and makes it more efficient.
It also adds a string_starts_with helper function - compatible with future C++20 upgrades.
There are no side-effects outside the auto_completion_callback function.

References

#19985

Requirements

@matthiasstraka matthiasstraka requested review from a team and ngxson as code owners April 10, 2026 21:04
if (string_starts_with(rel_pattern, '~')) {
const char * home = std::getenv("HOME");
if (home && home[0]) {
rel_pattern = std::string(home) + rel_pattern.substr(1);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
rel_pattern = std::string(home) + rel_pattern.substr(1);
rel_pattern = home + rel_pattern.substr(1);


// TODO?: Make this reusable, enums, docs
static const std::array<const std::string, 7> cmds = {
static const std::array<std::string_view, 7> cmds = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this C++23?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants