Skip to content

Commit

Permalink
add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkappa committed Mar 17, 2018
1 parent 0b2bc9d commit 2ccab73
Show file tree
Hide file tree
Showing 165 changed files with 25,461 additions and 532 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
.glide/
.wercker/
bin/*
*.sh
*.bat
66 changes: 57 additions & 9 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ VERSION ?= $(shell git describe --tags)
PKG = github.com/yieldr/navitaire-ods
PKGS = $(shell go list ./... | grep -v /vendor/ | grep -v /test)

# SENTRY_DSN ?= "https://[email protected]/304990"

LDFLAGS = "-s -w -X github.com/yieldr/navitaire-ods/pkg/version.Version=$(VERSION)"

OS ?= darwin
Expand Down
49 changes: 48 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,48 @@
# Yieldr - Navitaire ODS Flight Uploader
# Yieldr - Navitaire New Skies® ODS

Upload flight performance from [Navitaire New Skies](http://www.navitaire.com/p_new_skies.aspx) [Operational Data Store](http://www.navitaire.com/Styles/Images/PDFs/Data%20Store.pdf) to Yieldr.

## Download

Head over to the [releases](https://github.com/yieldr/navitaire-ods/releases) page and download a version appropriate for your operating system and architecture.

```
curl -sSL -o navitaire-ods https://github.com/yieldr/navitaire-ods/releases/download/v0.0.1-alpha.3/navitaire-ods-linux-amd64
```

## Usage

The `run` command queries the New Skies ODS database and uploads the flights to Yieldr using the [Yieldr API](https://api.yieldr.com/#272b3d39-2dfc-e7fe-7f65-f2cd4d0e841c).

```bash
navitaire-ods run \
--api \
--api-addr="<account>.yieldr.com" \
--api-client-id=<client-id> \
--api-client-secret=<client-secret> \
--api-project-id=<project-id> \
--db="sqlserver" \
--db-addr="localhost:1234" \
--db-name="NS34ODS" \
--db-user=<username> \
--db-pass=<password> \
--db-query="" \ # use the default query, see below
--db-query-args=<carrier-code>
```

Flags can alternatively be replace with environment variables. The convention is `YIELDR_` followed by the flag name in capital letters with dashes (`-`) replaced by undescores (`_`). For example the `--api-addr` flag can be defined as the `YIELDR_API_ADDR` environment variable.

### SQL Query

An [example SQL query](pkg/navitaire/ods/query.sql) is supplied for convenience, but in most cases you might want to customise it to match your use case.

## Yieldr API

To find your `client_id` and `client_secret` you will need to create a [Yieldr API Integration](https://help.yieldr.com/yieldr-api/section-heading/step-2-integrate-with-the-yieldr-api).

## SFTP

We plan to add support for uploading files using SFTP. As of this writing this is not supported, but might become available in the future.

For more information on the `run` command, check the reference [documentation](doc/navitaire-ods_run.md).

47 changes: 47 additions & 0 deletions cmd/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright © 2018 Yieldr

package cmd

import (
"fmt"
"os"

"github.com/spf13/cobra"
"github.com/spf13/cobra/doc"
"github.com/spf13/viper"
)

var cmdDoc = &cobra.Command{
Use: "doc",
Short: "Generate cli documentation",
Run: runDoc,
}

func runDoc(cmd *cobra.Command, args []string) {
dir, _ := cmd.Flags().GetString("dir")
format, _ := cmd.Flags().GetString("format")

var err error

switch format {
case "markdown":
err = doc.GenMarkdownTree(cmdRoot, dir)
case "rest":
err = doc.GenReSTTree(cmdRoot, dir)
case "man":
err = doc.GenManTree(cmdRoot, &doc.GenManHeader{}, dir)
}

if err != nil {
fmt.Println(err)
os.Exit(1)
}
}

func init() {
cmdRoot.AddCommand(cmdDoc)
cmdDoc.Flags().String("dir", "doc", "Directory in which to generate documentation")
cmdDoc.Flags().String("format", "markdown", "Format in which to generate documentation")
viper.BindPFlag("dir", cmdRun.Flags().Lookup("dir"))
viper.BindPFlag("format", cmdRun.Flags().Lookup("format"))
}
6 changes: 5 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import (
)

var cmdRoot = &cobra.Command{
Use: "navitaire-ods",
Use: "navitaire-ods",
Short: "Root command",
Long: `Yieldr - Navitaire ODS Flight Uploader
Use this program to query your Navitaire ODS database for flight performance and
Expand All @@ -35,4 +36,7 @@ func init() {
viper.SetEnvPrefix("YIELDR")
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
})

cmdRoot.PersistentFlags().BoolP("debug", "d", false, "Enable debug mode to print more verbose logs")
viper.BindPFlag("debug", cmdRoot.PersistentFlags().Lookup("debug"))
}
Loading

0 comments on commit 2ccab73

Please sign in to comment.