Skip to content

Commit

Permalink
feat(file_templates): Add filetemplates module for easy bootsrapping …
Browse files Browse the repository at this point in the history
…of common files (now editorconfig only)
  • Loading branch information
ondrejsika committed Aug 3, 2021
1 parent a33954c commit d2fa6e5
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
_ "github.com/sikalabs/slut/cmd/expand"
_ "github.com/sikalabs/slut/cmd/expand/file"
_ "github.com/sikalabs/slut/cmd/expand/string"
_ "github.com/sikalabs/slut/cmd/file_templates"
_ "github.com/sikalabs/slut/cmd/file_templates/editorconfig"
_ "github.com/sikalabs/slut/cmd/mysql"
_ "github.com/sikalabs/slut/cmd/mysql/create"
_ "github.com/sikalabs/slut/cmd/mysql/drop"
Expand Down
22 changes: 22 additions & 0 deletions cmd/file_templates/editorconfig/editorconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package editorconfig

import (
file_templates_cmd "github.com/sikalabs/slut/cmd/file_templates"
"github.com/sikalabs/slut/file_templates/editorconfig"

"github.com/spf13/cobra"
)

var Cmd = &cobra.Command{
Use: "editorconfig",
Short: "Create basic editorconfig",
Aliases: []string{"ec"},
Args: cobra.NoArgs,
Run: func(c *cobra.Command, args []string) {
editorconfig.CreateEditorconfig()
},
}

func init() {
file_templates_cmd.Cmd.AddCommand(Cmd)
}
16 changes: 16 additions & 0 deletions cmd/file_templates/file_templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package file_templates

import (
"github.com/sikalabs/slut/cmd/root"
"github.com/spf13/cobra"
)

var Cmd = &cobra.Command{
Use: "file-templates",
Short: "Create common files from templates",
Aliases: []string{"ft"},
}

func init() {
root.RootCmd.AddCommand(Cmd)
}
25 changes: 25 additions & 0 deletions file_templates/editorconfig/editorconfig.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package editorconfig

import "io/ioutil"

func CreateEditorconfig() {
content := []byte(`
root = true
[*]
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = off
[Makefile]
indent_style = tab
[*.go]
indent_style = tab
`)
err := ioutil.WriteFile(".editorconfig", content, 0644)
if err != nil {
panic(err)
}
}

0 comments on commit d2fa6e5

Please sign in to comment.