elliotchance / gedcom

👪 A Go library and CLI tools for encoding, decoding, traversing, merging, comparing, querying and publishing GEDCOM files.
MIT License
97 stars 22 forks source link

Explanatory docs? #315

Open ronaaron opened 4 years ago

ronaaron commented 4 years ago

New to this tool, downloaded the linux binary.

The usual "gedcom -?" or "help" or "-h" or "syntax" etc, provide no information on what to do specifically. It would be useful if the zip contained at least a synopsis of options and how to use them.

elliotchance commented 4 years ago

It's true, the docs aren't great but the wiki provides some information on the commands: https://github.com/elliotchance/gedcom/wiki

There is more technical information in the godocs linked from the bottom of the README per package.

The native Go flag package uses single dash for all arguments, so it would be: gedcom -help.

mabraden commented 3 years ago

Could you give me a little help with using the Windows executable? I'd like to query my gedcom file but can't determine the syntax. I successfully produced HTML with gedcom.exe publish treename.ged (very cool) and similarly "warnings" worked, but when I try to use query gedcom.exe query treename.ged I get the message "ERROR: you must specify at least one -gedcom file". I've tried appending queries after the filename based on what I learned about q, but that doesn't solve the problem. Thanks for any help you can suggest.

elliotchance commented 3 years ago

See https://github.com/elliotchance/gedcom/wiki/Query-Command:

gedcom query -gedcom file.ged '.Individuals | .Name'

On Windows, only the command changes:

gedcom.exe query -gedcom file.ged '.Individuals | .Name'

The '.Individuals | .Name' is the query you want to run. Keep in mind that it needs to be in quotes so that spaces are included.

mabraden commented 3 years ago

Thanks for the response. I get the following error when I use that line.

C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged '.Individuals | .Name' '.Name'' is not recognized as an internal or external command, operable program or batch file.

Similarly, I get an error with C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged '.Individuals | ?' '?'' is not recognized as an internal or external command, operable program or batch file.

Playing around, I can get single parameters after the file name to work without quotes:

C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged ? [".AddFamily",".AddFamilyWithHusbandAndWife",".AddIndividual",".AddNode",".DeleteNode",".Families",".GEDCOMString",".Individuals",".NodeByPointer",".Nodes",".Places",".SetNodes",".Sources",".String",".Warnings","?","Combine","Document1","First","Last","Length","MergeDocumentsAndIndividuals","NodesWithTagPath","Only"]

C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged .Individuals This works and gives a giant output as expected. I'm using a large tree from ancestry.com.

C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged Length 1

A single parameter with quotes does not work. C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged '.Individuals' 2021/02/24 10:54:20 ERROR: expected expression

If I put together multiple parameters with or without quotes I get trouble.

C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged '.Individuals | .Length' '.Length'' is not recognized as an internal or external command, operable program or batch file.

C:\Users\mabraden\Desktop\gedcom-windows\bin>gedcom query -gedcom BradenSchillerFamilyTree.ged .Individuals | .Length '.Length' is not recognized as an internal or external command, operable program or batch file.

Any other suggestions?

On Tue, Feb 23, 2021 at 12:05 PM Elliot Chance notifications@github.com wrote:

See https://github.com/elliotchance/gedcom/wiki/Query-Command:

gedcom query -gedcom file.ged '.Individuals | .Name'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/elliotchance/gedcom/issues/315#issuecomment-784395470, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFK5MG6AOIWLMFCZK772MYTTAPVAJANCNFSM4R5JAOCQ .

-- Marc Braden

mabraden commented 3 years ago

I have it working fine in Linux, so I'm good. Not sure what is up with the Windows version. Thanks.

On Tue, Feb 23, 2021 at 12:05 PM Elliot Chance notifications@github.com wrote:

See https://github.com/elliotchance/gedcom/wiki/Query-Command:

gedcom query -gedcom file.ged '.Individuals | .Name'

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/elliotchance/gedcom/issues/315#issuecomment-784395470, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFK5MG6AOIWLMFCZK772MYTTAPVAJANCNFSM4R5JAOCQ .

-- Marc Braden

elliotchance commented 3 years ago

I guess windows only allows double-quotes?

gedcom.exe query -gedcom file.ged ".Individuals | .Name"
mabraden commented 3 years ago

Arg. I was sure I had tried that, but probably had some other syntax issue at the same time. Thanks.

If you have a moment, is there a simple way to output only the descendents of one individual?

On Thu, Feb 25, 2021 at 8:54 AM Elliot Chance notifications@github.com wrote:

I guess windows only allows double-quotes?

gedcom.exe query -gedcom file.ged ".Individuals | .Name"

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/elliotchance/gedcom/issues/315#issuecomment-785955882, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFK5MG35GDM33YHANIEQBOTTAZQD3ANCNFSM4R5JAOCQ .

-- Marc Braden

elliotchance commented 3 years ago

Off the top of my head I don't think there is a way to get the recursive descendants, but if you only care about the immediate children this might work:

.Individuals | Only(.Name = "Bob Smith") | .Families | .Children
elliotchance commented 3 years ago

It looks like when godos changed their domain it broke the documentation links in this package. You can use this: https://pkg.go.dev/github.com/elliotchance/gedcom@v38.0.0+incompatible to explore the methods.

CraigEBridge commented 3 years ago

A really useful addition to gedcom.exe (Windows) would be to show the existing output that gedcom with no arguments shows after "ERROR" unknown command : Additionally, adding another line that indicates -help can be used with any of the commands to get usage

Old school mature command line programs that had any help with command lines embedded in them displayed hints as to how to see the usage info.

My first assumption was that there was no command line help or usage after typing "gedcom -help". I had to go fish for online documentation which took me about 10 minutes to find.

Point me at where the usage help is within the source and I'll see if I can come up with a simple embellishment for you. An "Old School Developer" (unix, SunOS, Windows [user and kernel mode] and earlier systems)

elliotchance commented 3 years ago

If you want to have a go at fixing the help flag that would be great since I don't really have time to work on this project anymore. I can explain where a few things are to point you in the right direction.

All the code for the gedcom command itself lives in this package: https://github.com/elliotchance/gedcom/tree/master/cmd/gedcom, the usage message is here: https://github.com/elliotchance/gedcom/blob/master/cmd/gedcom/main.go#L20-L32

To test your change you will need the go sdk installed (https://golang.org/doc/install), then simply:

git clone https://github.com/elliotchance/gedcom.git
cd gedcom/cmd/gedcom

go build
gedcom.exe