Skip to content

Commit

Permalink
Merge branch 'main' into improve-markdown-documents
Browse files Browse the repository at this point in the history
  • Loading branch information
skatkov authored Sep 26, 2023
2 parents e8e8681 + 6f8a960 commit 61d0006
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 44 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.18
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.48
version: v1.48
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:
inputs:
release_id:
description: 'Release id (tag name)'
description: "Release id (tag name)"
required: true
jobs:
create_release:
Expand All @@ -25,7 +25,7 @@ jobs:
- [**MacOS** Intel](https://github.com/skatkov/stoic/releases/download/${{ github.event.inputs.release_id }}/stoic-mac-intel.zip)
- [**MacOS** M1 (ARM)](https://github.com/skatkov/stoic/releases/download/${{ github.event.inputs.release_id }}/stoic-mac-arm.zip)
- [**Linux**](https://github.com/skatkov/stoic/releases/download/${{ github.event.inputs.release_id }}/stoic-linux.zip)
release_name: ${{ github.event.inputs.release_id }}
prerelease: true
draft: true
Expand All @@ -52,7 +52,7 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.18'
go-version: "1.18"
- name: Build binary
env:
GOOS: ${{ matrix.go_os }}
Expand Down
51 changes: 27 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,34 @@ jobs:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- run: go test ./...
- uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- uses: actions/checkout@v3
- run: go test ./...

test-cache:
strategy:
matrix:
go-version: [1.18.x]
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
- uses: actions/checkout@v3
- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- run: go test ./...
- uses: actions/setup-go@v3
with:
go-version: 1.18.x
- uses: actions/checkout@v3
- uses: actions/cache@v2
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ matrix.go-version }}-
- run: go test ./...
2 changes: 1 addition & 1 deletion cmd/about.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ type aboutCommand struct {
buildHash string
}

func NewAboutCommand(version string, buildHash string) AboutCommand {
func NewAboutCommand(version, buildHash string) AboutCommand {
return &aboutCommand{
version: version,
buildHash: buildHash,
Expand Down
2 changes: 0 additions & 2 deletions cmd/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ type editCommand struct {

func NewEditCommand(ctx stoic.Context, value string) EditCommand {
date, err := naturaldate.Parse(value, time.Now())

if err != nil {
fmt.Println("Error parsing date:", err)
os.Exit(1)
Expand All @@ -42,7 +41,6 @@ func (e *editCommand) Date() time.Time {
func (e *editCommand) Run() {
entry := stoic.NewEntry(e.ctx, e.date)
err := e.ctx.OpenInEditor(entry)

if err != nil {
fmt.Println("Error running program:", err)
os.Exit(1)
Expand Down
1 change: 0 additions & 1 deletion cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func (m model) View() string {
}

func OpenFileInEditor(filepath string, ctx stoic.Context) error {

cmd := exec.Command(ctx.Editor(), filepath)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
Expand Down
2 changes: 1 addition & 1 deletion cmd/quote.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ var (
BorderRight(true).
BorderBottom(true)

authoredBy = lipgloss.NewStyle().SetString("©").
authoredBy = lipgloss.NewStyle().SetString("").
PaddingRight(1).
Foreground(foreground).
String()
Expand Down
15 changes: 8 additions & 7 deletions internal/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ import (
homedir "github.com/mitchellh/go-homedir"
)

const DEFAULT_EDITOR = "nano"
const DEFAULT_DIRECTORY = "~/Journal/"
const DEFAULT_EXTENSION = "md"
const (
DEFAULT_EDITOR = "nano"
DEFAULT_DIRECTORY = "~/Journal/"
DEFAULT_EXTENSION = "md"
)

type Context interface {
Directory() string
Expand All @@ -31,7 +33,7 @@ type context struct {
template string
}

func NewContext(homeDir string, fileExtension string, editor string, template string) Context {
func NewContext(homeDir, fileExtension, editor, template string) Context {
directory := expandDir(homeDir)

if fileExtension == "" {
Expand Down Expand Up @@ -75,7 +77,7 @@ func (ctx *context) OpenInEditor(entry Entry) error {
return cmd.Run()
}

func createFileFromTemplate(filename string, template_path string) error {
func createFileFromTemplate(filename, template_path string) error {
file, err := os.Create(filename)
if err != nil {
return err
Expand Down Expand Up @@ -148,8 +150,7 @@ func (ctx context) Files() []string {

func createDirectoryIfMissing(dir string) error {
if _, err := os.Stat(dir); os.IsNotExist(err) {
err := os.MkdirAll(dir, 0755)

err := os.MkdirAll(dir, 0o755)
if err != nil {
return err
}
Expand Down
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
stoic "github.com/skatkov/stoic/internal"
)

var BinaryVersion string // Set via build flag
var BinaryBuildHash string // Set via build flag
var (
BinaryVersion string // Set via build flag
BinaryBuildHash string // Set via build flag
)

func main() {
ctx := stoic.NewContext(
Expand All @@ -38,7 +40,6 @@ func main() {
cmd.NewQuoteCommand().Run()
default:
err := ctx.OpenInEditor(stoic.NewEntry(ctx, time.Now()))

if err != nil {
fmt.Println(err)
}
Expand Down

0 comments on commit 61d0006

Please sign in to comment.