Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: ignore surronding whitespace for cli config#12250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Emyrk merged 2 commits intomainfromstevenmasley/cli-normalize-space
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
All reads normalized
  • Loading branch information
@Emyrk
Emyrk committedFeb 21, 2024
commitb396c25e66bbcebb24e9e0d987428b6810910570
13 changes: 3 additions & 10 deletionscli/config/file.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -86,21 +86,14 @@ func (f File) Write(s string) error {
return write(string(f), 0o600, []byte(s))
}

func (f File) ReadNormalizeSpace() (string, error) {
str, err := f.Read()
if err != nil {
return "", err
}
return strings.TrimSpace(str), nil
}

// Read reads the file to a string.
// Read reads the file to a string. All leading and trailing whitespace
// is removed.
func (f File) Read() (string, error) {
if f == "" {
return "", xerrors.Errorf("empty file path")
}
byt, err := read(string(f))
return string(byt), err
returnstrings.TrimSpace(string(byt)), err
}

// open opens a file in the configuration directory,
Expand Down
2 changes: 1 addition & 1 deletioncli/root.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -558,7 +558,7 @@ func (r *RootCmd) initClientInternal(client *codersdk.Client, allowTokenMissing
}

if r.token == "" {
r.token, err = conf.Session().ReadNormalizeSpace()
r.token, err = conf.Session().Read()
// If the configuration files are absent, the user is logged out
if os.IsNotExist(err) {
if !allowTokenMissing {
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp