Files
forever-files/cmd/cli/cli.go
2023-06-04 22:49:48 -06:00

62 lines
1.3 KiB
Go

package main
import (
"context"
"fmt"
"github.com/urfave/cli/v2"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"os"
"time"
)
func main() {
commands := []*cli.Command{
&cli.Command{
Name: "start",
Aliases: []string{"s"},
Usage: "Start the application service",
Action: func(c *cli.Context) error {
//d := daemon.NewDaemon()
//d.Start()
return nil
},
},
}
app := &cli.App{
Name: "ForeverFiles",
Usage: "Create backups designed to last forever",
Version: "v1.0.0",
Description: "ForeverFiles is a system for storing files forever.",
Commands: commands,
Flags: nil,
Authors: []*cli.Author{
{
Name: "Mason Payne",
Email: "mason@masonitestudios.com",
},
},
Copyright: fmt.Sprintf("%v Masonite Studios LLC", time.Now().Year()),
UseShortOptionHandling: true,
}
err := app.Run(os.Args)
if err != nil {
fmt.Println(fmt.Errorf("error running app | %w", err))
return
}
}
func getConn(dialAddr string) (*grpc.ClientConn, error) {
conn, err := grpc.DialContext(
context.Background(),
dialAddr,
//grpc.WithBlock(),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return &grpc.ClientConn{}, fmt.Errorf("failed to dial server: %w", err)
}
return conn, nil
}