Skip to content

Commit 2aaf90a

Browse files
committed
Initial implementation
1 parent e755d4f commit 2aaf90a

File tree

7 files changed

+166
-1
lines changed

7 files changed

+166
-1
lines changed

.github/dependabot.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: gomod
4+
directory: "/"
5+
schedule:
6+
interval: daily
7+
- package-ecosystem: github-actions
8+
directory: "/"
9+
schedule:
10+
interval: daily

.github/workflows/build.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
workflow_dispatch:
8+
inputs:
9+
tag:
10+
description: 'Tag to create'
11+
required: true
12+
default: 'v0.0.0'
13+
14+
# See https://github.com/cristalhq/.github/.github/workflows
15+
jobs:
16+
build:
17+
uses: cristalhq/.github/.github/workflows/build.yml@main
18+
19+
release:
20+
if: github.event_name == 'workflow_dispatch'
21+
uses: cristalhq/.github/.github/workflows/release.yml@main
22+
with:
23+
tag: ${{ github.event.input.tag }}

GUIDE.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Guide for appx
2+
3+
## Basic case
4+
5+
```go
6+
package main
7+
8+
import (
9+
"context"
10+
"os"
11+
12+
"github.com/cristalhq/appx"
13+
)
14+
15+
func main() {
16+
ctx := appx.Context()
17+
18+
if err := run(ctx, os.Args[1:]); err != nil {
19+
panic(err)
20+
}
21+
}
22+
23+
func run(ctx context.Context, args []string) error {
24+
// do good things
25+
return nil
26+
}
27+
```

README.md

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,70 @@
11
# appx
2-
Go library for building applications. Dramatically simple.
2+
3+
[![build-img]][build-url]
4+
[![pkg-img]][pkg-url]
5+
[![reportcard-img]][reportcard-url]
6+
[![coverage-img]][coverage-url]
7+
[![version-img]][version-url]
8+
9+
Go library for building applications. Dramatically simple. For a CLI tool see [acmd](https://github.com/cristalhq/acmd).
10+
11+
## Features
12+
13+
* Simple API.
14+
* Dependency-free.
15+
* Dramatically simple.
16+
17+
See [GUIDE.md](https://github.com/cristalhq/appx/blob/main/GUIDE.md) for more details
18+
19+
## Install
20+
21+
Go version 1.17+
22+
23+
```
24+
go get github.com/cristalhq/appx
25+
```
26+
27+
## Example
28+
29+
```go
30+
import (
31+
"context"
32+
"os"
33+
34+
"github.com/cristalhq/appx"
35+
)
36+
37+
func main() {
38+
ctx := appx.Context()
39+
40+
if err := run(ctx, os.Args[1:]); err != nil {
41+
panic(err)
42+
}
43+
}
44+
45+
func run(ctx context.Context, args []string) error {
46+
// do good things
47+
return nil
48+
}
49+
```
50+
51+
Also see examples: [examples_test.go](https://github.com/cristalhq/appx/blob/main/example_test.go).
52+
53+
## Documentation
54+
55+
See [these docs][pkg-url].
56+
57+
## License
58+
59+
[MIT License](LICENSE).
60+
61+
[build-img]: https://github.com/cristalhq/appx/workflows/build/badge.svg
62+
[build-url]: https://github.com/cristalhq/appx/actions
63+
[pkg-img]: https://pkg.go.dev/badge/cristalhq/appx
64+
[pkg-url]: https://pkg.go.dev/github.com/cristalhq/appx
65+
[reportcard-img]: https://goreportcard.com/badge/cristalhq/appx
66+
[reportcard-url]: https://goreportcard.com/report/cristalhq/appx
67+
[coverage-img]: https://codecov.io/gh/cristalhq/appx/branch/main/graph/badge.svg
68+
[coverage-url]: https://codecov.io/gh/cristalhq/appx
69+
[version-img]: https://img.shields.io/github/v/release/cristalhq/appx
70+
[version-url]: https://github.com/cristalhq/appx/releases

appx.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package appx
2+
3+
import (
4+
"context"
5+
"os/signal"
6+
"syscall"
7+
)
8+
9+
// Context of the application listening SIGINT and SIGTERM signals.
10+
func Context() context.Context {
11+
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM)
12+
return ctx
13+
}

example_test.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package appx_test
2+
3+
import (
4+
"context"
5+
"os"
6+
7+
"github.com/cristalhq/appx"
8+
)
9+
10+
func main() {
11+
ctx := appx.Context()
12+
13+
if err := run(ctx, os.Args[1:]); err != nil {
14+
panic(err)
15+
}
16+
}
17+
18+
func run(ctx context.Context, args []string) error {
19+
// do good things
20+
return nil
21+
}

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/cristalhq/appx
2+
3+
go 1.17

0 commit comments

Comments
 (0)