-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move main.go to top level directory for now
- Loading branch information
Showing
2 changed files
with
57 additions
and
84 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,57 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
|
||
"github.com/SwayKh/linksym/pkg/config" | ||
"github.com/SwayKh/linksym/pkg/linker" | ||
) | ||
|
||
// var ( | ||
// add = flag.Bool("add", false, "add a symlink to given path") | ||
// remove = flag.Bool("remove", false, "Remove a symlink") | ||
// help = flag.Bool("--help", false, "Print this help message") | ||
// h = flag.Bool("-h", false, "Print this help message") | ||
// ) | ||
|
||
var usage string = ` | ||
Usage: linksym [option...] [path...] | ||
Options: | ||
add add a symlink to given path | ||
remove Remove a symlink | ||
-h Print this help message | ||
` | ||
|
||
func main() { | ||
if len(os.Args) < 2 { | ||
fmt.Println(usage) | ||
os.Exit(1) | ||
} | ||
|
||
configPath, err := config.Initialise() | ||
if err != nil { | ||
// fmt.Errorf("Error initialising config: %s", err) | ||
fmt.Println(err) | ||
} | ||
|
||
cfg, err := config.LoadConfig("./.linksym.yaml") | ||
if err != nil { | ||
// fmt.Errorf("Error loading config: %s", err) | ||
fmt.Println(err) | ||
} | ||
|
||
sourcePath := os.Args[1] | ||
filename := filepath.Base(sourcePath) | ||
// destinationPath := os.Args[2] | ||
destinationPath := cfg.InitDirectory + "/" + filename | ||
|
||
fmt.Println(sourcePath, filename, destinationPath) | ||
|
||
err = linker.Link(sourcePath, destinationPath, configPath) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
} |