Browse Source

v0.1.5 Build 0523

pull/103/head
Unknown 12 years ago
parent
commit
f67a560661
  1. 4
      README.md
  2. 9
      conf/gpm.toml
  3. 9
      doc/github.go
  4. 85
      docs/Quick_Start.md
  5. 17
      gpm.go
  6. 2
      gpm_test.go

4
README.md

@ -20,8 +20,8 @@ This application still in experiment, any change could happen, but it doesn't af
## Main commands
- `build` compiles and installs packages and dependencies: basically, it calls `go install` and moves executable to current path from `GOPATH` if any, the executable name is the folder name which is default by `go install`.
- `install` downloads and installs packages and dependencies: you can download packages without version control tools like git, hg, svn, etc. It downloads and installs all packages including all dependencies automatically(except when you use bundle or snapshot id). For now, this command supports `code.google.com`, `github.com`, `launchpad.net`, `bitbucket.org`.
- `remove` removes packages and dependencies: it removes all packages including all dependencies(except when you use bundle or snapshot id).
- `install` downloads and installs packages and dependencies: you can download packages without version control tools like git, hg, svn, etc. It downloads and installs all packages including all dependencies automatically(except when you use bundle or snapshot). For now, this command supports `code.google.com`, `github.com`, `launchpad.net`, `bitbucket.org`.
- `remove` removes packages and dependencies: it removes all packages including all dependencies(except when you use bundle or snapshot).
## Known issues

9
conf/gpm.toml

@ -1,8 +1,11 @@
# This is a configuration file for gpm with toml format.
title = "gpm(Go Package Manager)"
version = "v0.1.5 Build 0522"
version = "v0.1.5 Build 0523"
user_language = "en-US"
#user_language = "zh-CN"
[account]
username = ""
password = ""
user_language = "en-US"
#user_language = "zh-CN"
github_access_token = ""

9
doc/github.go

@ -22,13 +22,16 @@ var (
githubCred string
)
func SetGithubCredentials(id, secret string) {
githubCred = "client_id=" + id + "&client_secret=" + secret
/*func SetGithubCredentials(id, secret string) {
//githubCred = "client_id=" + id + "&client_secret=" + secret
}*/
func SetGithubCredentials(token string) {
githubCred = "access_token=" + token
}
// GetGithubDoc downloads tarball from github.com.
func GetGithubDoc(client *http.Client, match map[string]string, installGOPATH string, node *Node, cmdFlags map[string]bool) ([]string, error) {
SetGithubCredentials("1862bcb265171f37f36c", "308d71ab53ccd858416cfceaed52d5d5b7d53c5f")
match["cred"] = githubCred
// JSON struct for github.com.

85
docs/Quick_Start.md

@ -0,0 +1,85 @@
# Quick Start
**Attention** Features like bundle and snapshot have NOT been published for users.
Full documentation please visit [GPMGo Documentation]().
## Index
- [When and why](#when-and-why)
- [Installation](#installation)
- [ **Build** your first project](#build-your-first-project)
- [ Download and **install** package, or packages](#download-and-install-package,-or-packages)
- [ **Remove** package, or packages](#remove-package,-or-packages)
## When and why
- No version control tool are installed, too lazy to have it?
Go get gpm!
- Killer feature over `go get`?
There is almost nothing better than `go get` until we make feature bundle and snapshot be available to you.
## Installation
You can install either from source or download binary.
### Install from source
- gpm is a `go get` able project: execute command `go get github.com/GPMGo/gpm` to download and install.
- Run test: switch work directory to gpm project, and execute command `go test` to build and test commands automatically(for now, tested commands are `gpm install`, `gpm remove`).
- Add gpm project path to your environment variable `PATH` in order to execute it from other directories.
### Download binary
Because we don't have all kinds of operating systems, we need your help to complete following download list!(I'm just too lazy to cross compiling -_-|||)
- darwin-386:
- darwin-amd64:
- freebsd-386:
- freebsd-amd64:
- linux-386:
- linux-amd64:
- Windows_386:
- Windows_amd64:
**Attention** Because we use API to get information of packages that are hosted on github.com, but it limits 60 requests per hour, so you may get errors if you download too much(more than 50 packages per hour). We do not provider access token for secure reason, but we do have configure option `github_access_token` in configuration file `conf/gpm.toml`, so you can go to [here](https://github.com/settings/applications) and create your personal access token, and set it in `gpm.toml`.
## Build your first project
Command `build` compiles and installs packages along with all dependencies.
Suppose you have a project called `github.com/GPMGo/gpm`.
- Switch to corresponding directory: `cd $GOPATH/src/github.com/GPMGo/gpm`.
- Execute command `gpm build`.
- Then, gpm calls `go install` in underlying, so you should have binary `$GOPATH/bin/gpm`.
- gpm moves binary from corresponding GOPATH to current which is `$GOPATH/src/github.com/GPMGo/` in this case, now just run your application.
### Why we do this?
In some cases like building web applications, we use relative path to access static files, and `go build` compiles packages without saving, so it's a shortcut for `go install` + `go build`, and you don't need to compile packages which have not changed again.
Also, you can use all flags that are used for `go install`.
## Download and install package, or packages
Command `install` downloads and installs packages along with all dependencies(except when you use bundle or snapshot).
Suppose you want to install package `bitbucket.org/zombiezen/gopdf/pdf`.
- Execute command `gpm install -p bitbucket.org/zombiezen/gopdf/pdf`, flag `-p` means **pure download** (download packages without version control), so you do not need to install version control tool. In case you want to, `gpm install bitbucket.org/zombiezen/gopdf/pdf` calls `go get` in underlying.
- gpm tells your which GOPATH will be used for saving packages, and it checks your current execute path to get best matched path in your GOPATH environment variable.
## Remove package, or packages
Command `remove` removes packages from your local file system(except when you use bundle or snapshot).
Suppose you want to remove package `bitbucket.org/zombiezen/gopdf/pdf`.
- Execute command `gpm remove bitbucket.org/zombiezen/gopdf/pdf`, gpm finds this project in all paths in your GOPATH environment.
- You may notice this is not project path, it's OK because gpm knows it, and deletes directory `$GOPATH/src/bitbucket.org/zombiezen/gopdf/`.

17
gpm.go

@ -39,9 +39,14 @@ var (
var promptMsg map[string]string
type tomlConfig struct {
Title, Version string
Username, Password string
Lang string `toml:"user_language"`
Title, Version string
Lang string `toml:"user_language"`
Account account
}
type account struct {
Username, Password string
Github_Access_Token string `toml:"github_access_token"`
}
// A Command is an implementation of a go command
@ -251,6 +256,9 @@ func loadLocalBundles() bool {
// We don't use init() to initialize
// bacause we need to get execute path in runtime.
func initialize() bool {
// Try to have highest performance.
runtime.GOMAXPROCS(runtime.NumCPU())
// Get application execute path.
if !getAppPath() {
return false
@ -262,6 +270,9 @@ func initialize() bool {
return false
}
// Set github.com access token.
doc.SetGithubCredentials(config.Account.Github_Access_Token)
// Load usages by language.
if !loadUsage(config.Lang) {
return false

2
gpm_test.go

@ -10,7 +10,7 @@ import (
)
func TestGPM(t *testing.T) {
fmt.Println("gpm v0.1.5 Build 0522")
fmt.Println("gpm v0.1.5 Build 0523")
// Build application.
var args []string

Loading…
Cancel
Save