Skip to content

Commit

Permalink
Return calendar as default output of nepcal (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
mesaugat authored Dec 2, 2021
1 parent eeaf384 commit f9b43fe
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 30 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ vendor/
# Binaries
bin/
dist/
nepcal

# Project specific files
cmd/cross/reference.json
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@ Nepcal is a command line tool and a library that provides several functionalitie

## Table of Contents

* [Command Line](#command-line)
* [Installation](#installation)
* [Pre-built binaries](#pre-built-binaries)
* [Homebrew on Mac](#homebrew-on-mac)
* [Using go get](#using-go-get)
* [Usage](#usage)
* [Monthly Calendar](#monthly-calendar)
* [Today's date and day](#todays-date-and-day)
* [Convert an A.D. date to B.S.](#convert-an-ad-date-to-bs)
* [Convert a B.S. date to A.D.](#convert-a-bs-date-to-ad)
* [Library/Programmatic usage](#library)
* [Acknowledgements](#acknowledgements)
* [Contributing](#contributing)
* [License](#license)
- [Command Line](#command-line)
- [Installation](#installation)
- [Pre-built binaries](#pre-built-binaries)
- [Homebrew on Mac](#homebrew-on-mac)
- [Using go get](#using-go-get)
- [Usage](#usage)
- [Monthly Calendar](#monthly-calendar)
- [Today's date and day](#todays-date-and-day)
- [Convert an A.D. date to B.S.](#convert-an-ad-date-to-bs)
- [Convert a B.S. date to A.D.](#convert-a-bs-date-to-ad)
- [Library/Programmatic usage](#library)
- [Acknowledgements](#acknowledgements)
- [Contributing](#contributing)
- [License](#license)

## Command Line

The `nepcal` CLI was initially inspired from the `cal` command on Linux, but expanded to have much more functionality, namely:

* [x] Show the current Nepali month's calendar (Similar to `cal`)
* [x] Show today's Nepali date and day
* [x] Convert A.D. (gregorian) dates to B.S. dates and vice-versa.
- Show the current Nepali month's calendar (Similar to `cal`)
- Show today's Nepali date and day
- Convert A.D. (gregorian) dates to B.S. dates and vice-versa.

## Installation

Expand Down Expand Up @@ -66,12 +66,12 @@ $ go get -v github.com/srishanbhattarai/nepcal/cmd/nepcal

## Usage

Complete details can be found by running `nepcal` without any arguments.
Complete details can be found by running `nepcal help`.

### Monthly Calendar

```sh
$ nepcal cal # or nepcal c
$ nepcal # or nepcal cal
चैत ११, २०७६
Su Mo Tu We Th Fr Sa
Expand Down
8 changes: 4 additions & 4 deletions cmd/nepcal/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func (nepcalCli) convADToBS(c *cli.Context) error {
if !validateArgs(c) {
fmt.Fprintln(os.Stderr, "Please supply a valid date in the format mm-dd-yyyy. Example: `nepcal conv tobs 08-21-1994`")

return cli.NewExitError("", 1)
return cli.Exit("", 1)
}

mm, dd, yy, _ := parseRawDate(c.Args().First())
Expand All @@ -54,7 +54,7 @@ func (nepcalCli) convADToBS(c *cli.Context) error {
if err != nil {
fmt.Fprintln(os.Stderr, "Please supply a date after 04/14/1943.")

return cli.NewExitError("", 1)
return cli.Exit("", 1)
}

fmt.Fprintln(globalWriter, bs.String())
Expand All @@ -67,7 +67,7 @@ func (nepcalCli) convBSToAD(c *cli.Context) error {
if !validateArgs(c) {
fmt.Fprintln(os.Stderr, "Please supply a valid date in the format mm-dd-yyyy. Example: `nepcal conv toad 08-18-2053`")

return cli.NewExitError("", 1)
return cli.Exit("", 1)
}

mm, dd, yy, _ := parseRawDate(c.Args().First())
Expand All @@ -76,7 +76,7 @@ func (nepcalCli) convBSToAD(c *cli.Context) error {
if err != nil {
fmt.Fprintln(os.Stderr, "Please ensure the date is between 1/1/2000 and 12/30/2095")

return cli.NewExitError("", 1)
return cli.Exit("", 1)
}

printGregorian(globalWriter, d.Gregorian())
Expand Down
11 changes: 8 additions & 3 deletions cmd/nepcal/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/urfave/cli/v2"
)

const version = "v1.1.0"
const version = "v1.3.0"

// Cheap testing.
var globalWriter io.Writer = os.Stdout
Expand All @@ -38,8 +38,13 @@ func bootstrapCli() *cli.App {
Name: "nepcal",
Version: version,
Usage: "Calendar and conversion utilities for Nepali dates",
HideVersion: true,
HideHelpCommand: true,
HideVersion: false,
HideHelpCommand: false,
Action: nc.showCalendar,
CommandNotFound: func(c *cli.Context, command string) {
fmt.Printf("No matching sub command: %s\n\n", command)
cli.ShowAppHelpAndExit(c, 1)
},
Authors: []*cli.Author{
{
Name: "Srishan Bhattarai",
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.17
require (
github.com/fatih/color v1.9.0
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.2.0
github.com/urfave/cli/v2 v2.3.0
)

require (
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/urfave/cli/v2 v2.2.0 h1:JTTnM6wKzdA0Jqodd966MVj4vWbbquZykeX1sKbe2C4=
github.com/urfave/cli/v2 v2.2.0/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ=
github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037 h1:YyJpGZS1sBuBCzLAR1VEpK193GlqGZbnPFnPV/5Rsb4=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit f9b43fe

Please sign in to comment.