本文整理汇总了Golang中github.com/js-arias/cmdapp.Command.Usage方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Usage方法的具体用法?Golang Command.Usage怎么用?Golang Command.Usage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/js-arias/cmdapp.Command
的用法示例。
在下文中一共展示了Command.Usage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: txSetRun
func txSetRun(c *cmdapp.Command, args []string) {
openLocal(c)
var tax *jdh.Taxon
if len(idFlag) > 0 {
tax = taxon(c, localDB, idFlag)
if len(tax.Id) == 0 {
return
}
} else if (len(args) > 0) && (strings.Index(args[0], "=") < 0) {
name := args[0]
pName := ""
args = args[1:]
if (len(args) > 0) && (strings.Index(args[0], "=") < 0) {
pName = args[0]
args = args[1:]
}
tax = pickTaxName(c, localDB, name, pName)
if len(tax.Id) == 0 {
return
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong taxon name or id"))
c.Usage()
}
vals := valsFromArgs(tax.Id, args)
localDB.Exec(jdh.Set, jdh.Taxonomy, vals)
localDB.Exec(jdh.Commit, "", nil)
}
示例2: raLsRun
func raLsRun(c *cmdapp.Command, args []string) {
openLocal(c)
var tax *jdh.Taxon
if len(taxonFlag) > 0 {
tax = taxon(c, localDB, taxonFlag)
if len(tax.Id) == 0 {
return
}
} else if len(args) > 0 {
if len(args) > 2 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
os.Exit(1)
}
pName := ""
if len(args) > 1 {
pName = args[1]
}
tax = pickTaxName(c, localDB, args[0], pName)
if len(tax.Id) == 0 {
return
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong taxon name or id"))
c.Usage()
}
vals := new(jdh.Values)
if childFlag {
vals.Add(jdh.RDisTaxonParent, tax.Id)
} else {
vals.Add(jdh.RDisTaxon, tax.Id)
}
l := rasList(c, localDB, vals)
defer l.Close()
ct := tax
for {
ras := &jdh.Raster{}
if err := l.Scan(ras); err != nil {
if err == io.EOF {
break
}
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
os.Exit(1)
}
if machineFlag {
fmt.Fprintf(os.Stdout, "%s\n", ras.Id)
continue
}
if ras.Taxon != ct.Id {
ct = taxon(c, localDB, ras.Taxon)
}
if verboseFlag {
fmt.Fprintf(os.Stdout, "%s %s %s\t%s\t%dx%d\n", ct.Id, ct.Name, ct.Authority, ras.Id, ras.Cols, ras.Cols/2)
continue
}
fmt.Fprintf(os.Stdout, "%s\t%s\t%dx%d\n", ct.Name, ras.Id, ras.Cols, ras.Cols/2)
}
}
示例3: dsSetRun
func dsSetRun(c *cmdapp.Command, args []string) {
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong dataset id"))
c.Usage()
}
openLocal(c)
set := dataset(c, localDB, idFlag)
if len(set.Id) == 0 {
return
}
vals := valsFromArgs(set.Id, args)
localDB.Exec(jdh.Set, jdh.Datasets, vals)
localDB.Exec(jdh.Commit, "", nil)
}
示例4: raSetRun
func raSetRun(c *cmdapp.Command, args []string) {
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong specimen id"))
c.Usage()
}
openLocal(c)
ras := raster(c, localDB, idFlag)
if len(ras.Id) == 0 {
return
}
vals := valsFromArgs(ras.Id, args)
localDB.Exec(jdh.Set, jdh.RasDistros, vals)
localDB.Exec(jdh.Commit, "", nil)
}
示例5: dsDelRun
func dsDelRun(c *cmdapp.Command, args []string) {
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong dataset id"))
c.Usage()
}
openLocal(c)
vals := new(jdh.Values)
vals.Add(jdh.KeyId, idFlag)
if _, err := localDB.Exec(jdh.Delete, jdh.Datasets, vals); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
os.Exit(1)
}
localDB.Exec(jdh.Commit, "", nil)
}
示例6: trSetRun
func trSetRun(c *cmdapp.Command, args []string) {
openLocal(c)
if len(nodeFlag) > 0 {
trSetNode(c, args)
return
}
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong tree or node id"))
c.Usage()
}
phy := phylogeny(c, localDB, idFlag)
if len(phy.Id) == 0 {
return
}
vals := valsFromArgs(phy.Id, args)
localDB.Exec(jdh.Set, jdh.Trees, vals)
localDB.Exec(jdh.Commit, "", nil)
}
示例7: trDelRun
func trDelRun(c *cmdapp.Command, args []string) {
openLocal(c)
if len(nodeFlag) > 0 {
trDelNode(c)
return
}
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong tree or node id"))
c.Usage()
}
vals := new(jdh.Values)
vals.Add(jdh.KeyId, idFlag)
if _, err := localDB.Exec(jdh.Delete, jdh.Trees, vals); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
os.Exit(1)
}
localDB.Exec(jdh.Commit, "", nil)
}
示例8: spDelRun
func spDelRun(c *cmdapp.Command, args []string) {
openLocal(c)
vals := new(jdh.Values)
if len(idFlag) > 0 {
vals.Add(jdh.KeyId, idFlag)
if _, err := localDB.Exec(jdh.Delete, jdh.Specimens, vals); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
os.Exit(1)
}
localDB.Exec(jdh.Commit, "", nil)
return
}
var tax *jdh.Taxon
if len(taxonFlag) > 0 {
tax = taxon(c, localDB, taxonFlag)
if len(tax.Id) == 0 {
return
}
} else if len(args) > 0 {
if len(args) > 2 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
os.Exit(1)
}
pName := ""
if len(args) > 1 {
pName = args[1]
}
tax = pickTaxName(c, localDB, args[0], pName)
if len(tax.Id) == 0 {
return
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong specimen id or taxon name or id"))
c.Usage()
}
vals.Add(jdh.SpeTaxon, tax.Id)
if _, err := localDB.Exec(jdh.Delete, jdh.Specimens, vals); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
os.Exit(1)
}
localDB.Exec(jdh.Commit, "", nil)
}
示例9: spPopRun
func spPopRun(c *cmdapp.Command, args []string) {
if len(extDBFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong '--extdb' option"))
c.Usage()
}
openLocal(c)
openExt(c, extDBFlag, "")
var tax *jdh.Taxon
if len(taxonFlag) > 0 {
tax = taxon(c, localDB, taxonFlag)
if len(tax.Id) == 0 {
return
}
} else if len(args) > 0 {
if len(args) > 2 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
os.Exit(1)
}
pName := ""
if len(args) > 1 {
pName = args[1]
}
tax = pickTaxName(c, localDB, args[0], pName)
if len(tax.Id) == 0 {
return
}
} else {
tax = &jdh.Taxon{}
}
rank := jdh.Kingdom
if len(rankFlag) > 0 {
rank = jdh.GetRank(rankFlag)
if rank == jdh.Unranked {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("invalid rank"))
os.Exit(1)
}
}
spPopFetch(c, tax, jdh.Kingdom, rank)
localDB.Exec(jdh.Commit, "", nil)
}
示例10: raInfoRun
func raInfoRun(c *cmdapp.Command, args []string) {
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong raster id"))
c.Usage()
}
openLocal(c)
ras := raster(c, localDB, idFlag)
if len(ras.Id) == 0 {
return
}
if machineFlag {
if len(keyFlag) == 0 {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.RDisTaxon, ras.Taxon)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.RDisSource, ras.Source)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyReference, ras.Reference)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.RDisCols, ras.Cols)
for _, e := range ras.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, ras.Comment)
return
}
switch jdh.Key(keyFlag) {
case jdh.RDisTaxon:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.RDisTaxon, ras.Taxon)
case jdh.RDisSource:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.RDisSource, ras.Source)
case jdh.RDisCols:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.RDisCols, ras.Cols)
case jdh.KeyExtern:
for _, e := range ras.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
case jdh.KeyComment:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, ras.Comment)
case jdh.KeyReference:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyReference, ras.Reference)
}
return
}
if len(keyFlag) == 0 {
tax := taxon(c, localDB, ras.Taxon)
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Id:", ras.Id)
fmt.Fprintf(os.Stdout, "%-16s %s %s [id: %s]\n", "Taxon:", tax.Name, tax.Authority, ras.Taxon)
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Source:", ras.Source)
fmt.Fprintf(os.Stdout, "%-16s %dx%d\n", "Dimensions:", ras.Cols, ras.Cols/2)
if len(ras.Reference) > 0 {
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Reference:", ras.Reference)
}
if len(ras.Extern) > 0 {
fmt.Fprintf(os.Stdout, "Extern ids:\n")
for _, e := range ras.Extern {
fmt.Fprintf(os.Stdout, "\t%s\n", e)
}
}
if len(ras.Comment) > 0 {
fmt.Fprintf(os.Stdout, "Comments:\n%s\n", ras.Comment)
}
return
}
switch jdh.Key(keyFlag) {
case jdh.RDisTaxon:
fmt.Fprintf(os.Stdout, "%s\n", ras.Taxon)
case jdh.RDisSource:
fmt.Fprintf(os.Stdout, "%s\n", ras.Source)
case jdh.RDisCols:
fmt.Fprintf(os.Stdout, "%s\n", ras.Cols)
case jdh.KeyExtern:
for _, e := range ras.Extern {
fmt.Fprintf(os.Stdout, "%s\n", e)
}
case jdh.KeyComment:
fmt.Fprintf(os.Stdout, "%s\n", ras.Comment)
case jdh.KeyReference:
fmt.Fprintf(os.Stdout, "%s\n", ras.Reference)
}
}
示例11: txInfoRun
func txInfoRun(c *cmdapp.Command, args []string) {
var db jdh.DB
if len(extDBFlag) != 0 {
openExt(c, extDBFlag, "")
db = extDB
} else {
openLocal(c)
db = localDB
}
var tax *jdh.Taxon
if len(idFlag) > 0 {
tax = taxon(c, db, idFlag)
if len(tax.Id) == 0 {
return
}
} else if len(args) > 0 {
if len(args) > 2 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
os.Exit(1)
}
pName := ""
if len(args) > 1 {
pName = args[1]
}
tax = pickTaxName(c, db, args[0], pName)
if len(tax.Id) == 0 {
return
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong taxon name or id"))
c.Usage()
}
if machineFlag {
if len(keyFlag) == 0 {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxName, tax.Name)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxAuthority, tax.Authority)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxRank, tax.Rank)
if tax.IsValid {
fmt.Fprintf(os.Stdout, "%s=true\n", jdh.TaxValid)
} else {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxSynonym, tax.Parent)
}
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxParent, tax.Parent)
for _, e := range tax.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, tax.Comment)
return
}
switch jdh.Key(keyFlag) {
case jdh.TaxName:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxName, tax.Name)
case jdh.TaxAuthority:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxAuthority, tax.Authority)
case jdh.TaxRank:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxRank, tax.Rank)
case jdh.TaxValid, jdh.TaxSynonym:
if tax.IsValid {
fmt.Fprintf(os.Stdout, "%s=true\n", jdh.TaxValid)
} else {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxSynonym, tax.Parent)
}
case jdh.TaxParent:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TaxParent, tax.Parent)
case jdh.KeyExtern:
for _, e := range tax.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
case jdh.KeyComment:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, tax.Comment)
}
return
}
if len(keyFlag) == 0 {
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Id:", tax.Id)
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Name:", tax.Name)
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Authority:", tax.Authority)
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Rank:", tax.Rank)
if tax.IsValid {
fmt.Fprintf(os.Stdout, "%-16s true\n", "Valid:")
} else {
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Synonym of:", tax.Parent)
}
if len(tax.Parent) > 0 {
p := taxon(c, db, tax.Parent)
fmt.Fprintf(os.Stdout, "%-16s %s %s [id: %s]\n", "Parent:", p.Name, p.Authority, p.Id)
}
if len(tax.Extern) > 0 {
fmt.Fprintf(os.Stdout, "Extern ids:\n")
for _, e := range tax.Extern {
fmt.Fprintf(os.Stdout, "\t%s\n", e)
}
}
if len(tax.Comment) > 0 {
fmt.Fprintf(os.Stdout, "Comments:\n%s\n", tax.Comment)
}
txInfoList(c, db, tax.Id, true)
txInfoList(c, db, tax.Id, false)
return
}
//.........这里部分代码省略.........
示例12: spLsRun
func spLsRun(c *cmdapp.Command, args []string) {
var db jdh.DB
if len(extDBFlag) != 0 {
openExt(c, extDBFlag, "")
db = extDB
} else {
openLocal(c)
db = localDB
}
var tax *jdh.Taxon
if len(taxonFlag) > 0 {
tax = taxon(c, db, taxonFlag)
if len(tax.Id) == 0 {
return
}
} else if len(args) > 0 {
if len(args) > 2 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
os.Exit(1)
}
pName := ""
if len(args) > 1 {
pName = args[1]
}
tax = pickTaxName(c, db, args[0], pName)
if len(tax.Id) == 0 {
return
}
} else {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong taxon name or id"))
c.Usage()
}
vals := new(jdh.Values)
if childFlag {
vals.Add(jdh.SpeTaxonParent, tax.Id)
} else {
vals.Add(jdh.SpeTaxon, tax.Id)
}
if len(countryFlag) > 0 {
vals.Add(jdh.GeoCountry, countryFlag)
}
if geoRefFlag {
vals.Add(jdh.SpeGeoref, "true")
} else if noRefFlag {
vals.Add(jdh.SpeGeoref, "false")
}
l := speList(c, db, vals)
defer l.Close()
ct := tax
for {
spe := &jdh.Specimen{}
if err := l.Scan(spe); err != nil {
if err == io.EOF {
break
}
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr(err))
os.Exit(1)
}
if machineFlag {
fmt.Fprintf(os.Stdout, "%s\n", spe.Id)
continue
}
if spe.Taxon != ct.Id {
ct = taxon(c, db, spe.Taxon)
}
if verboseFlag {
fmt.Fprintf(os.Stdout, "%s %s %s\t%s %s", ct.Id, ct.Name, ct.Authority, spe.Id, spe.Catalog)
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "\t%.5f %.5f %d", spe.Georef.Point.Lon, spe.Georef.Point.Lat, spe.Georef.Uncertainty)
}
fmt.Fprintf(os.Stdout, "\n")
continue
}
fmt.Fprintf(os.Stdout, "%s\t%s", ct.Name, spe.Catalog)
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "\t%.5f %.5f", spe.Georef.Point.Lon, spe.Georef.Point.Lat)
}
fmt.Fprintf(os.Stdout, "\n")
}
}
示例13: trInfoRun
func trInfoRun(c *cmdapp.Command, args []string) {
openLocal(c)
if len(nodeFlag) > 0 {
trInfoNode(c)
return
}
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong tree or node id"))
c.Usage()
}
phy := phylogeny(c, localDB, idFlag)
if len(phy.Id) == 0 {
return
}
if machineFlag {
if len(keyFlag) == 0 {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TreName, phy.Name)
for _, e := range phy.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, phy.Comment)
return
}
switch jdh.Key(keyFlag) {
case jdh.TreName:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.TreName, phy.Name)
case jdh.KeyExtern:
for _, e := range phy.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
case jdh.KeyComment:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, phy.Comment)
}
return
}
if len(keyFlag) == 0 {
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Id:", phy.Id)
if len(phy.Name) > 0 {
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Name:", phy.Name)
}
fmt.Fprintf(os.Stdout, "%-16s %s\n", "Root:", phy.Root)
if len(phy.Extern) > 0 {
fmt.Fprintf(os.Stdout, "Extern ids:\n")
for _, e := range phy.Extern {
fmt.Fprintf(os.Stdout, "\t%s\n", e)
}
}
if len(phy.Comment) > 0 {
fmt.Fprintf(os.Stdout, "Comments:\n%s\n", phy.Comment)
}
return
}
switch jdh.Key(keyFlag) {
case jdh.TreName:
fmt.Fprintf(os.Stdout, "%s\n", phy.Name)
case jdh.KeyExtern:
for _, e := range phy.Extern {
fmt.Fprintf(os.Stdout, "%s\n", e)
}
case jdh.KeyComment:
fmt.Fprintf(os.Stdout, "%s\n", phy.Comment)
}
}
示例14: txSyncRun
func txSyncRun(c *cmdapp.Command, args []string) {
if len(extDBFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong '--extdb' option"))
c.Usage()
}
openLocal(c)
openExt(c, extDBFlag, "")
var tax *jdh.Taxon
if len(idFlag) > 0 {
tax = taxon(c, localDB, idFlag)
if len(tax.Id) == 0 {
return
}
} else if len(args) > 0 {
if len(args) > 2 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("too many arguments"))
os.Exit(1)
}
pName := ""
if len(args) > 1 {
pName = args[1]
}
tax = pickTaxName(c, localDB, args[0], pName)
if len(tax.Id) == 0 {
return
}
} else {
tax = &jdh.Taxon{}
}
noFlag := true
if matchFlag {
txSyncMatch(c, tax)
localDB.Exec(jdh.Commit, "", nil)
noFlag = false
}
if updateFlag || validFlag {
txSyncUpdate(c, tax)
localDB.Exec(jdh.Commit, "", nil)
noFlag = false
}
if len(rankFlag) > 0 {
rank := jdh.GetRank(rankFlag)
if rank == jdh.Unranked {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("invalid rank"))
os.Exit(1)
}
txSyncRank(c, tax, rank)
localDB.Exec(jdh.Commit, "", nil)
noFlag = false
}
if len(popFlag) > 0 {
rank := jdh.GetRank(popFlag)
if rank == jdh.Unranked {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("invalid rank"))
os.Exit(1)
}
prev := tax.Rank
if prev == jdh.Unranked {
prev = jdh.Kingdom
}
txSyncPop(c, tax, prev, rank)
localDB.Exec(jdh.Commit, "", nil)
noFlag = false
}
if noFlag {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("undefined action"))
c.Usage()
}
}
示例15: spInfoRun
func spInfoRun(c *cmdapp.Command, args []string) {
if len(idFlag) == 0 {
fmt.Fprintf(os.Stderr, "%s\n", c.ErrStr("expectiong specimen id"))
c.Usage()
}
var db jdh.DB
if len(extDBFlag) != 0 {
openExt(c, extDBFlag, "")
db = extDB
} else {
openLocal(c)
db = localDB
}
spe := specimen(c, db, idFlag)
if len(spe.Id) == 0 {
return
}
if machineFlag {
if len(keyFlag) == 0 {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeTaxon, spe.Taxon)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeBasis, spe.Basis)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyReference, spe.Reference)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeDataset, spe.Dataset)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeCatalog, spe.Catalog)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeDeterminer, spe.Determiner)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeCollector, spe.Collector)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeDate, spe.Date.Format(jdh.Iso8601))
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoCountry, spe.Geography.Country)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoState, spe.Geography.State)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoCounty, spe.Geography.County)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeLocality, spe.Locality)
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "%s=%.8f,%.8f\n", jdh.GeoLonLat, spe.Georef.Point.Lon, spe.Georef.Point.Lat)
fmt.Fprintf(os.Stdout, "%s=%d\n", jdh.GeoUncertainty, spe.Georef.Uncertainty)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoSource, spe.Georef.Source)
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoValidation, spe.Georef.Validation)
} else {
fmt.Fprintf(os.Stdout, "%s=\n", jdh.GeoLonLat)
fmt.Fprintf(os.Stdout, "%s=0\n", jdh.GeoUncertainty)
fmt.Fprintf(os.Stdout, "%s=\n", jdh.GeoSource)
fmt.Fprintf(os.Stdout, "%s=\n", jdh.GeoValidation)
}
for _, e := range spe.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyComment, spe.Comment)
return
}
switch jdh.Key(keyFlag) {
case jdh.SpeTaxon:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeTaxon, spe.Taxon)
case jdh.SpeBasis:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeBasis, spe.Basis)
case jdh.SpeDataset:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeDataset, spe.Dataset)
case jdh.SpeCatalog:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeCatalog, spe.Catalog)
case jdh.SpeDeterminer:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeDeterminer, spe.Determiner)
case jdh.SpeCollector:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeCollector, spe.Collector)
case jdh.SpeDate:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeDate, spe.Date.Format(jdh.Iso8601))
case jdh.GeoCountry:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoCountry, spe.Geography.Country)
case jdh.GeoState:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoState, spe.Geography.State)
case jdh.GeoCounty:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoCounty, spe.Geography.County)
case jdh.SpeLocality:
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.SpeLocality, spe.Locality)
case jdh.GeoLonLat:
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "%s=%.8f,%.8f\n", jdh.GeoLonLat, spe.Georef.Point.Lon, spe.Georef.Point.Lat)
} else {
fmt.Fprintf(os.Stdout, "%s=\n", jdh.GeoLonLat)
}
case jdh.GeoUncertainty:
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "%s=%d\n", jdh.GeoUncertainty, spe.Georef.Uncertainty)
} else {
fmt.Fprintf(os.Stdout, "%s=0\n", jdh.GeoUncertainty)
}
case jdh.GeoSource:
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoSource, spe.Georef.Source)
} else {
fmt.Fprintf(os.Stdout, "%s=\n", jdh.GeoSource)
}
case jdh.GeoValidation:
if spe.Georef.IsValid() {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.GeoValidation, spe.Georef.Validation)
} else {
fmt.Fprintf(os.Stdout, "%s=\n", jdh.GeoValidation)
}
case jdh.KeyExtern:
for _, e := range spe.Extern {
fmt.Fprintf(os.Stdout, "%s=%s\n", jdh.KeyExtern, e)
}
case jdh.KeyComment:
//.........这里部分代码省略.........