This repository has been archived by the owner on Jul 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some new ideas to fix botway config file issue on railway
- Loading branch information
Showing
6 changed files
with
75 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package app | ||
|
||
import ( | ||
"github.com/abdfnx/botway/constants" | ||
"github.com/abdfnx/botway/internal/pipes/initx" | ||
"github.com/abdfnx/botway/tools" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func DockerInitCMD() *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "docker-init", | ||
Short: "Initialize ~/.botway for docker containers", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
if opts.CopyFile { | ||
tools.Copy("botway.json", constants.BotwayDirPath) | ||
} else { | ||
initx.DockerInit() | ||
} | ||
}, | ||
} | ||
|
||
cmd.Flags().BoolVarP(&opts.CopyFile, "copy-file", "", false, "Copy config file") | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package tools | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"os" | ||
) | ||
|
||
func Copy(src, dst string) (int64, error) { | ||
sourceFileStat, err := os.Stat(src) | ||
|
||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
if !sourceFileStat.Mode().IsRegular() { | ||
return 0, fmt.Errorf("%s is not a regular file", src) | ||
} | ||
|
||
source, err := os.Open(src) | ||
|
||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
defer source.Close() | ||
|
||
destination, err := os.Create(dst) | ||
|
||
if err != nil { | ||
return 0, err | ||
} | ||
|
||
defer destination.Close() | ||
|
||
nBytes, err := io.Copy(destination, source) | ||
|
||
return nBytes, err | ||
} |