Esempio n. 1
0
func NewImporter(rw bool, gopath string, premap map[string]string) (*Importer, error) {
	cfg, err := gx.LoadConfig()
	if err != nil {
		return nil, err
	}

	pm, err := gx.NewPM(cfg)
	if err != nil {
		return nil, err
	}

	if premap == nil {
		premap = make(map[string]string)
	}

	bctx := build.Default
	bctx.GOPATH = gopath

	return &Importer{
		pkgs:    make(map[string]*gx.Dependency),
		gopath:  gopath,
		pm:      pm,
		rewrite: rw,
		preMap:  premap,
		bctx:    bctx,
	}, nil
}
Esempio n. 2
0
func main() {
	cfg, err := gx.LoadConfig()
	if err != nil {
		Fatal(err)
	}

	pm, err = gx.NewPM(cfg)
	if err != nil {
		Fatal(err)
	}

	app := cli.NewApp()
	app.Author = "whyrusleeping"
	app.Version = "0.3"
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:  "verbose",
			Usage: "print verbose logging information",
		},
	}
	app.Before = func(c *cli.Context) error {
		Verbose = c.Bool("verbose")

		gcwd, err := os.Getwd()
		if err != nil {
			return err
		}
		cwd = gcwd

		return nil
	}

	app.Usage = "gx is a packaging tool that uses ipfs"

	app.Commands = []cli.Command{
		CleanCommand,
		DepsCommand,
		GetCommand,
		ImportCommand,
		InitCommand,
		InstallCommand,
		PublishCommand,
		RepoCommand,
		UpdateCommand,
		VersionCommand,
		ViewCommand,
	}

	app.RunAndExitOnError()
}