This repository has been archived by the owner on Mar 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from everettraven/feature/markdown-console-output
Feature/markdown console output
- Loading branch information
Showing
19 changed files
with
6,622 additions
and
6,348 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
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 |
---|---|---|
@@ -1,77 +1,78 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/everettraven/packageless/subcommands" | ||
"github.com/everettraven/packageless/utils" | ||
) | ||
|
||
func main() { | ||
exitCode, exitErr := wrappedMain() | ||
|
||
if exitErr != nil { | ||
fmt.Println(exitErr) | ||
} | ||
|
||
os.Exit(exitCode) | ||
} | ||
|
||
func wrappedMain() (int, error) { | ||
//Create the utils for the subcommands | ||
util := utils.NewUtility() | ||
|
||
//Create the copier for the subcommands | ||
cp := &utils.CopyTool{} | ||
|
||
//Config file location | ||
configLoc, err := os.UserHomeDir() | ||
|
||
if err != nil { | ||
return 1, err | ||
} | ||
|
||
configLoc = configLoc + "/.packageless/config.hcl" | ||
|
||
configBody, err := util.GetHCLBody(configLoc) | ||
|
||
if err != nil { | ||
return 1, err | ||
} | ||
|
||
//Parse the config file | ||
parseOut, err := util.ParseBody(configBody, utils.Config{}) | ||
|
||
if err != nil { | ||
return 1, err | ||
} | ||
|
||
config := parseOut.(utils.Config) | ||
|
||
if strings.Contains(config.BaseDir, "~") { | ||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
return 1, err | ||
} | ||
config.BaseDir = strings.Replace(config.BaseDir, "~", homeDir, 1) | ||
} | ||
|
||
//Create the list of subcommands | ||
scmds := []subcommands.Runner{ | ||
subcommands.NewInstallCommand(util, cp, config), | ||
subcommands.NewUninstallCommand(util, config), | ||
subcommands.NewUpgradeCommand(util, cp, config), | ||
subcommands.NewRunCommand(util, config), | ||
subcommands.NewVersionCommand(), | ||
subcommands.NewUpdateCommand(util, config), | ||
} | ||
|
||
//Run the subcommands | ||
if err := subcommands.SubCommand(os.Args[1:], scmds); err != nil { | ||
return 1, err | ||
} | ||
|
||
return 0, nil | ||
} | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"strings" | ||
|
||
"github.com/everettraven/packageless/subcommands" | ||
"github.com/everettraven/packageless/utils" | ||
) | ||
|
||
func main() { | ||
exitCode, exitErr := wrappedMain() | ||
|
||
if exitErr != nil { | ||
errString := "# ERROR\n" + "**Encountered an error:** *%s*\n" | ||
utils.NewUtility().RenderErrorMarkdown(fmt.Sprintf(errString, exitErr.Error())) | ||
} | ||
|
||
os.Exit(exitCode) | ||
} | ||
|
||
func wrappedMain() (int, error) { | ||
//Create the utils for the subcommands | ||
util := utils.NewUtility() | ||
|
||
//Create the copier for the subcommands | ||
cp := &utils.CopyTool{} | ||
|
||
//Config file location | ||
configLoc, err := os.UserHomeDir() | ||
|
||
if err != nil { | ||
return 1, err | ||
} | ||
|
||
configLoc = configLoc + "/.packageless/config.hcl" | ||
|
||
configBody, err := util.GetHCLBody(configLoc) | ||
|
||
if err != nil { | ||
return 1, err | ||
} | ||
|
||
//Parse the config file | ||
parseOut, err := util.ParseBody(configBody, utils.Config{}) | ||
|
||
if err != nil { | ||
return 1, err | ||
} | ||
|
||
config := parseOut.(utils.Config) | ||
|
||
if strings.Contains(config.BaseDir, "~") { | ||
homeDir, err := os.UserHomeDir() | ||
if err != nil { | ||
return 1, err | ||
} | ||
config.BaseDir = strings.Replace(config.BaseDir, "~", homeDir, 1) | ||
} | ||
|
||
//Create the list of subcommands | ||
scmds := []subcommands.Runner{ | ||
subcommands.NewInstallCommand(util, cp, config), | ||
subcommands.NewUninstallCommand(util, config), | ||
subcommands.NewUpgradeCommand(util, cp, config), | ||
subcommands.NewRunCommand(util, config), | ||
subcommands.NewVersionCommand(util), | ||
subcommands.NewUpdateCommand(util, config), | ||
} | ||
|
||
//Run the subcommands | ||
if err := subcommands.SubCommand(os.Args[1:], scmds); err != nil { | ||
return 1, err | ||
} | ||
|
||
return 0, nil | ||
} |
Oops, something went wrong.