aboutsummaryrefslogtreecommitdiff
path: root/steam-export-cli.go
diff options
context:
space:
mode:
authorMitch Riedstra <mitch@riedstra.us>2017-01-16 11:30:06 -0500
committerMitch Riedstra <mitch@riedstra.us>2017-01-16 11:30:06 -0500
commitd5679be63fe396b5bcd2f01b76799a17a64a83d4 (patch)
treeb32e44dc01738a7bbfd44e50ed8ef7b3d6ca667c /steam-export-cli.go
parentab2338daadbb826063c1ff299a9e39bb41e40317 (diff)
downloadsteam-export-d5679be63fe396b5bcd2f01b76799a17a64a83d4.tar.gz
steam-export-d5679be63fe396b5bcd2f01b76799a17a64a83d4.tar.xz
Added ability to extract games. Initial code to delete games. Initial basic progress on a command line application.
Diffstat (limited to 'steam-export-cli.go')
-rw-r--r--steam-export-cli.go70
1 files changed, 70 insertions, 0 deletions
diff --git a/steam-export-cli.go b/steam-export-cli.go
new file mode 100644
index 0000000..46f96dd
--- /dev/null
+++ b/steam-export-cli.go
@@ -0,0 +1,70 @@
+package main
+
+import (
+ "errors"
+ "flag"
+ "fmt"
+ "os"
+
+ "git.riedstra.us/mitch/steam-export/steam"
+)
+
+var (
+ errorHandling flag.ErrorHandling = flag.ExitOnError
+
+ defaultLib string = "C:\\Program Files (x86)\\Steam\\steamapps"
+ steamLib *steam.Library = &steam.Library{}
+)
+
+func parseArgs(args []string) error {
+ if len(args) < 2 {
+ return errors.New("Not enough arguments")
+ }
+ switch a := args[1]; a {
+ case "list":
+ return listGames(args[2:])
+ default:
+ printHelp()
+ }
+
+ return nil
+}
+
+func printHelp() {
+ fmt.Printf(`Program usage:
+steam-export-cli $subcommand $options
+Subcommands:
+ list -l $steam_library
+ package -l $steam_library -f $output_file [ -G $game_index | -g "game_name" ]
+ extract -l $steam_library -f $input_file
+ delete -l $steam_library [ -G $game_index | -g $game_name ]
+ server -c $config_file -l $steam_library -L $listen_addr`)
+
+}
+
+func listGames(args []string) error {
+ fl := flag.NewFlagSet("list", errorHandling)
+ lib := fl.String("l", defaultLib,
+ "Path to library in question. All the way to the 'steamapps' folder")
+
+ l := defaultLib
+ fl.Parse(args)
+ if fl.Parsed() {
+ l = string(*lib)
+ }
+
+ if err := steamLib.ProcessLibrary(l); err != nil {
+ return err
+ }
+
+ fmt.Println(steamLib)
+
+ return nil
+}
+
+func main() {
+ if err := parseArgs(os.Args); err != nil {
+ fmt.Fprintln(os.Stderr, err)
+ printHelp()
+ }
+}