Skip to content

Commit

Permalink
docs: readme, webstorm config, license
Browse files Browse the repository at this point in the history
  • Loading branch information
hugojosefson committed Jun 11, 2024
1 parent 47e92b4 commit 96bf4a9
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/sponge.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright © 2024 Hugo Josefson

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# sponge

Reimplementation of `sponge(1)` from
[moreutils](https://joeyh.name/code/moreutils/), for Deno.

[![JSR](https://jsr.io/badges/@moreutils/sponge)](https://jsr.io/@moreutils/sponge)
[![CI](https://github.com/hugojosefson/sponge/actions/workflows/deno.yaml/badge.svg)](https://github.com/hugojosefson/sponge/actions/workflows/deno.yaml)

## Requirements

Requires [Deno](https://deno.land/) v1.44.1 or later.

## Usage

### Soak up stdin, write to stdout

```sh
deno run jsr:@moreutils/sponge
```

### Soak up stdin, write to a file

```sh
deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
```

### Soak up stdin, append to a file

```sh
deno run --allow-write=file.txt jsr:@moreutils/sponge -a file.txt
```

## Example usage

Given a file `file.txt` with the following contents:

```
The quick brown fox jumps over the lazy dog.
The foo bar baz.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
```

Running this command, will replace its contents with the same, piped through
`sed`:

```sh
cat file.txt |
sed -e 's/foo/bar/' |
deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
```
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"all-reload": " deno fmt && deno lint && deno task check-reload && deno task readme && deno task test --reload && deno task coverage --reload",
"check": " deno task foreach-file -- deno check '{}'",
"check-reload": "deno task foreach-file -- deno check --reload '{}'",
"test": " deno test --coverage --allow-run --allow-env=VERBOSE --allow-write=test.db --allow-read=test.db",
"test": " deno test --coverage --clean",
"coverage": " deno coverage",
"readme": " touch README.md && chmod +w README.md && ./readme/generate-readme.ts readme/README.md > README.md && deno fmt README.md; chmod -w README.md",
"release": " deno task all && test -z \"$(git status --porcelain)\" && GITHUB_TOKEN=$(gh auth token) deno run --allow-env=GITHUB_TOKEN --allow-net=api.github.com --allow-run=bash https://deno.land/x/shipit@0.6.1/shipit.ts",
Expand Down
46 changes: 46 additions & 0 deletions readme/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# sponge

Reimplementation of `sponge(1)` from
[moreutils](https://joeyh.name/code/moreutils/), for Deno.

[![JSR](https://jsr.io/badges/@moreutils/sponge)](https://jsr.io/@moreutils/sponge)
[![CI](https://github.com/hugojosefson/sponge/actions/workflows/deno.yaml/badge.svg)](https://github.com/hugojosefson/sponge/actions/workflows/deno.yaml)

## Requirements

Requires [Deno](https://deno.land/) v1.44.1 or later.

## Usage

### Soak up stdin, write to stdout

```sh
deno run jsr:@moreutils/sponge
```

### Soak up stdin, write to a file

```sh
deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
```

### Soak up stdin, append to a file

```sh
deno run --allow-write=file.txt jsr:@moreutils/sponge -a file.txt
```

## Example usage

Given a file `file.txt` with the following contents:

```
@@include(./file.txt)
```

Running this command, will replace its contents with the same, piped through
`sed`:

```sh
"@@include(./example-usage.sh)";
```
4 changes: 4 additions & 0 deletions readme/example-usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash
cat file.txt |
sed -e 's/foo/bar/' |
deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
5 changes: 0 additions & 5 deletions readme/example-usage.ts

This file was deleted.

5 changes: 5 additions & 0 deletions readme/file.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The quick brown fox jumps over the lazy dog.

The foo bar baz.

Lorem ipsum dolor sit amet, consectetur adipiscing elit.
8 changes: 0 additions & 8 deletions readme/install.sh

This file was deleted.

3 changes: 3 additions & 0 deletions readme/usage.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

deno run --allow-write=file.txt jsr:@moreutils/sponge file.txt
Empty file added src/sponge.ts
Empty file.

0 comments on commit 96bf4a9

Please sign in to comment.