diff --git a/.gitignore b/.gitignore index 2ac73c2..b6f4702 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,6 @@ go.work # Flux Feed fluxfeed flux-feed +fluxctl .env flux-local.db \ No newline at end of file diff --git a/Makefile b/Makefile index 780ef80..4a7d8d1 100644 --- a/Makefile +++ b/Makefile @@ -15,11 +15,11 @@ vet: fmt .PHONY:vet build: vet - go build -o ./fluxfeed . + go build -o ./fluxctl . .PHONY:build clean: - rm -rf ./fluxfeed + rm -rf ./fluxctl .PHONY:clean docs: diff --git a/README.md b/README.md index 7c1fe09..b1646db 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,25 @@ # Flux Feed ![build-status](https://drone.runcible.io/api/badges/androiddrew/flux-feed/status.svg) +[![](https://img.shields.io/badge/License-AGPL-blue.svg)](https://opensource.org/licenses/AGPL "License: AGPL") -An Indie Reader for the modern day. \ No newline at end of file +An Indie Reader for the modern day. + + +## Building + +From the root of the source tree run: + +```shell +make build +``` + +## Using + +```shell +./fluxctl --help +``` + +## License + +is project is licensed under the MIT License. See the [LICENSE file](https://git.runcible.io/androiddrew/flux-feed/src/branch/main/LICENSE) for the full license text. \ No newline at end of file diff --git a/cmd/migrate/main.go b/cmd/migrate.go similarity index 61% rename from cmd/migrate/main.go rename to cmd/migrate.go index e26b0d6..8bb7193 100644 --- a/cmd/migrate/main.go +++ b/cmd/migrate.go @@ -1,5 +1,5 @@ -// Entry point for applying database migrations for flux-feed application -package main +// Package cmd migrate provides a database migration command to root cli +package cmd import ( "database/sql" @@ -8,11 +8,12 @@ import ( "git.runcible.io/androiddrew/flux-feed/config" "github.com/golang-migrate/migrate/v4" "github.com/golang-migrate/migrate/v4/database/sqlite3" - _ "github.com/golang-migrate/migrate/v4/source/file" - _ "github.com/mattn/go-sqlite3" + _ "github.com/golang-migrate/migrate/v4/source/file" //migrations + _ "github.com/mattn/go-sqlite3" //migrations + "github.com/spf13/cobra" ) -func main() { +func runMigrate(_ *cobra.Command, _ []string) { cfg := config.New() db, err := sql.Open(cfg.DatabaseDriver, cfg.DatabaseDSN) defer db.Close() @@ -38,3 +39,10 @@ func main() { log.Fatal(err) } } + +// MigrateCmd provides database migrations command for cli +var MigrateCmd = &cobra.Command{ + Use: "migrate", + Short: "Run database migrations", + Run: runMigrate, +} diff --git a/cmd/root.go b/cmd/root.go new file mode 100644 index 0000000..9be1437 --- /dev/null +++ b/cmd/root.go @@ -0,0 +1,26 @@ +// Package cmd provides cli commands +package cmd + +import ( + "fmt" + "os" + + "github.com/spf13/cobra" +) + +var rootCmd = &cobra.Command{ + Use: "fluxctl", + Short: "A flexible indie reader for the modern day", +} + +// Execute executes the root command. +func Execute() { + if err := rootCmd.Execute(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +func init() { + rootCmd.AddCommand(MigrateCmd) +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..9bf1287 --- /dev/null +++ b/main.go @@ -0,0 +1,10 @@ +// Flux Feed main entrypoint +package main + +import ( + "git.runcible.io/androiddrew/flux-feed/cmd" +) + +func main() { + cmd.Execute() +}