Exemple #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
}
Exemple #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()
}
Exemple #3
0
			}
			delete(cfg.ExtraRepos, name)
		}

		err = gx.WriteConfig(cfg, cfp)
		if err != nil {
			Fatal(err)
		}
	},
}

var RepoListCommand = cli.Command{
	Name:  "list",
	Usage: "list tracked repos or packages in a repo",
	Action: func(c *cli.Context) {
		cfg, err := gx.LoadConfig()
		if err != nil {
			Fatal(err)
		}

		if !c.Args().Present() {
			tabPrintSortedMap(nil, cfg.GetRepos())
			return
		}

		rname := c.Args().First()
		r, ok := cfg.GetRepos()[rname]
		if !ok {
			Fatal("no such repo: ", rname)
		}