Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reload repo: Append .yaml unless already present #80

Merged
merged 1 commit into from
Jul 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pkg/yukictl/cmd/reload.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func NewCmdReload(f factory.Factory) *cobra.Command {
Short: "Reload config of one or all repos",
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) > 0 {
o.repo = args[0]
o.repo = stripSuffix(args[0])
}
return o.Run(f)
},
Expand Down
2 changes: 1 addition & 1 deletion pkg/yukictl/cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func NewCmdSync(f factory.Factory) *cobra.Command {
Example: " yukictl sync REPO",
Short: "Sync local repository with remote",
RunE: func(cmd *cobra.Command, args []string) error {
o.name = args[0]
o.name = stripSuffix(args[0])
return o.Run(f)
},
}
Expand Down
9 changes: 9 additions & 0 deletions pkg/yukictl/cmd/util.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package cmd

import "strings"

const suffixYAML = ".yaml"
Copy link
Member

Choose a reason for hiding this comment

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

Yuki 接受 .yml 后缀的配置吗?

Copy link
Member Author

Choose a reason for hiding this comment

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

no


func stripSuffix(s string) string {
return strings.TrimSuffix(s, suffixYAML)
}