Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌍 mommy adds a variety of things (but mostly global config files)~ #96

Merged
merged 5 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 32 additions & 17 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ jobs:
- name: Build packages
run: make dist/generic dist/apk dist/deb dist/rpm dist/pacman
- name: Upload built package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-linux
path: dist/mommy*

build-macos:
Expand All @@ -71,9 +71,9 @@ jobs:
- name: Build package
run: make dist/osxpkg
- name: Upload built package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-macos
path: dist/mommy*

build-freebsd:
Expand Down Expand Up @@ -114,9 +114,9 @@ jobs:

gmake dist/freebsd
- name: Upload built package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-freebsd
path: dist/mommy*

build-netbsd:
Expand Down Expand Up @@ -146,9 +146,9 @@ jobs:
gmake dist/netbsd
echo "::endgroup::"
- name: Upload built package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-netbsd
path: dist/mommy*

build-openbsd:
Expand Down Expand Up @@ -182,9 +182,9 @@ jobs:

gmake dist/openbsd
- name: Upload built package
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: dist
name: dist-openbsd
path: dist/mommy*


Expand All @@ -199,12 +199,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Download built packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
pattern: dist-*
merge-multiple: true
path: dist
- name: Extract release notes
id: extract-release-notes
uses: ffurrer2/extract-release-notes@v1
uses: ffurrer2/extract-release-notes@v2
with:
release_notes_file: RELEASE_NOTES.md
- name: Prepend release notes
Expand Down Expand Up @@ -244,9 +246,10 @@ jobs:
# Required to push '.deb' to repository
token: ${{ secrets.personal_access_token }}
- name: Download built packages
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: dist
pattern: dist-*
merge-multiple: true
path: dist-mommy
- name: Move .deb into apt-mommy
run: cp dist-mommy/*.deb apt-mommy/deb/
Expand Down Expand Up @@ -321,6 +324,12 @@ jobs:
- name: Update build files
working-directory: aur-mommy
run: |
if [ "${{ github.event.inputs.dry_run }}" = "false" ]; then
empty_option=""
else
empty_option="--allow-empty"
fi;

echo "::group::Fast-forward main"
sudo -u build git checkout dev
sudo -u build git checkout master
Expand All @@ -335,7 +344,7 @@ jobs:
sudo -u build git config --global user.name "FWDekkerBot"
sudo -u build git config --global user.email "[email protected]"
sudo -u build git add --all
sudo -u build git commit -m "🔖 mommy updated the build files to mommy $MOMMY_VERSION~"
sudo -u build git commit -m "🔖 mommy updated the build files to mommy $MOMMY_VERSION~" "$empty_option"
echo "::endgroup::"

echo "::group::Fast-forward dev"
Expand Down Expand Up @@ -376,6 +385,12 @@ jobs:
- name: Update formula
working-directory: homebrew-mommy
run: |
if [ "${{ github.event.inputs.dry_run }}" = "false" ]; then
empty_option=""
else
empty_option="--allow-empty"
fi;

echo "::group::Fast-forward main"
git checkout dev
git checkout main
Expand All @@ -390,7 +405,7 @@ jobs:
git config --global user.name "FWDekkerBot"
git config --global user.email "[email protected]"
git add --all
git commit -m "🔖 mommy updated the formula to mommy $MOMMY_VERSION~"
git commit -m "🔖 mommy updated the formula to mommy $MOMMY_VERSION~" "$empty_option"
echo "::endgroup::"

echo "::group::Fast-forward dev"
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
# Changelog
## [unreleased]
### added
* 🌍 mommy now supports a global config file that applies to all users, stored for example in `/usr/mommy/config.sh`~ ([#95](https://github.com/FWDekker/mommy/issues/95)) ([#96](https://github.com/FWDekker/mommy/issues/96))
* 📏 mommy accepts long command-line options for all options (like `--config=<file>` for `-c <file>`)~

### changed
* 🕳️ mommy now interprets an empty config file path (`-c`) as you not wanting to use a config file~
* ✅ mommy improved her input validation, giving clearer error messages when something is wrong~
* 🏓 mommy improved the links to and from the table of contents in her readme~


## [1.3.0] -- 2024-01-10
### added
* 🪹 mommy now supports newlines in templates using `%%N%%`~ ([#58](https://github.com/FWDekker/mommy/issues/58)) ([#82](https://github.com/FWDekker/mommy/issues/82))
Expand Down
87 changes: 55 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

---

🚚&nbsp;[**installation**](#-installation) | 📖&nbsp;[**usage**](#-usage) | 🙋&nbsp;[**configuration**](#-configuration) | 🐚&nbsp;[**shell integration**](#-shell-integration) | ⚗️&nbsp;[**development**](#%EF%B8%8F-development) | 💖&nbsp;[**acknowledgements**](#-acknowledgements)
<a name="toc"></a>🚚&nbsp;[**installation**](#installation) | 📖&nbsp;[**usage**](#usage) | 🙋&nbsp;[**configuration**](#configuration) | 🐚&nbsp;[**shell integration**](#shell-integration) | ⚗️&nbsp;[**development**](#development) | 💖&nbsp;[**acknowledgements**](#acknowledgements)

---

Expand All @@ -20,7 +20,7 @@ much~ ❤️
![mommy demo](.github/img/demo.gif)


## 🚚 installation
## 🚚 installation<a name="installation"></a> <small><sup>[top ▲](#toc)</sup></small>
mommy works on any system.
mommy is tested on ubuntu, debian, archlinux, fedora, nixpkgs, macos, freebsd, netbsd, openbsd, and windows~

Expand Down Expand Up @@ -214,7 +214,7 @@ find your operating system and package manager for the right instructions~
})
];
```
check [the full list of configuration options](#-configuration).
check [the full list of configuration options](#configuration).
note that your nix configuration should use lowercase variable names~
* **nixos** (persistent)
install mommy by adding the following to your nixos configuration (usually in `/etc/nixos/configuration.nix`):
Expand All @@ -234,7 +234,7 @@ find your operating system and package manager for the right instructions~
})
];
```
check [the full list of configuration options](#-configuration).
check [the full list of configuration options](#configuration).
note that your nix configuration should use lowercase variable names~

</details>
Expand Down Expand Up @@ -398,48 +398,71 @@ tar -C ./ -xzf mommy-*.tar.gz
</details>

### 🔮 what's next?
check out [how to use mommy](#-usage), read all about [ways you can configure mommy](#-configuration), and
[integrate mommy with your shell](#-shell-integration)~
check out [how to use mommy](#usage), read all about [ways you can configure mommy](#configuration), and
[integrate mommy with your shell](#shell-integration)~

<img width="450px" src=".github/img/sample1.png" alt="mommy integrated with the fish shell" />


## 📖 usage
mommy integrates with your normal command-line usage and compliments you if the command succeeds and encourages you if
it fails~
## 📖 usage<a name="usage"></a> <small><sup>[top ▲](#toc)</sup></small>
mommy processes the output status of a command and compliments you if the command succeeds and encourages you if it
fails~

you can ask mommy to support you in a few ways, shown below.
alternatively, you can [integrate mommy into your shell](#shell-integration) so `mommy` is invoked for each command~

```shell
$ mommy [-1] [-c config] [command] ...
$ mommy [command] ...
# e.g. `mommy npm test`

$ mommy [-1] [-c config] -e eval
$ mommy -e eval
# e.g. `mommy -e "ls -l | wc -l"`

$ mommy [-1] [-c config] -s status
# e.g. `mommy -s $?`
$ mommy -s status
# e.g. `mommy -s 0` or `mommy -s $?`
```

by default, mommy outputs to stderr, but if you use `mommy -1 [other options]` she'll output to stdout~

use `mommy -v` to see which version of mommy you're using~


## 🙋 configuration
mommy's behavior can be configured by defining variables in `~/.config/mommy/config.sh`.

> ℹ️ mommy is used to instructions being scribbled down in unusual places, and will check inside `XDG_CONFIG_HOME`
> instead of `~/.config/` if the former is set~

you can specify a different config file by pointing the environment variable `MOMMY_OPT_CONFIG_FILE` to that file, or by
running mommy as `mommy -c ./my_config.sh [other options]`~
additionally, mommy knows a few extra options, which you can use to discover who mommy is and to tell mommy which
[configuration files](#configuration) she should use.

| short option | long option | description |
|--------------|-------------------------------|-------------------------------------------------------------------------------------------|
| `-h` | `--help` | opens mommy's manual page~ |
| `-v` | `--version` | displays version information~ |
| `-1` | | writes output to stdout instead of stderr~ |
| `-c <file>` | `--config=<file>` | reads [config](#configuration) from `<file>`~ |
| | `--global-config-dirs=<dirs>` | sets global [configuration](#configuration) dirs to the colon-separated list in `<dirs>`~ |


## 🙋 configuration<a name="configuration"></a> <small><sup>[top ▲](#toc)</sup></small>
mommy's behavior can be configured using config files.
the easiest way to do so is to add your config to the file `~/.config/mommy/config.sh`.
you can also set up a global config file that is applied to all users in `/etc/mommy/config.sh`.
mommy will explain in detail below~

### 🔍 config file locations
when mommy runs, she will first load the system-wide **global** config file.
after that, she will read the user-specific **local** config file, overriding the values from the global file~

* to find the **global** config file, mommy runs the following procedure.
1. mommy determines the list of global config dirs.
1. if a list is specified using a [command-line option](#usage), that list is used.
2. otherwise, the list consists of all directories in `$XDG_CONFIG_DIRS`, plus `/etc/mommy`, plus
`/usr/local/etc/mommy/`.
2. mommy traverses this list, and stops once she finds a directory that contains the file `config.sh`.
this file will be the global config file~
* to find the **local** config file, mommy runs the following procedure.
1. if a config file is specified using a [command-line option](#usage), that file is used.
2. if `$XDG_CONFIG_HOME` is defined, the file `$XDG_CONFIG_HOME/mommy/config.sh` is used.
3. otherwise, `$HOME/.config/mommy/config.sh` is used~

### 🗃️ config file format
mommy executes the config file as a shell script and keeps the environment variables.
mommy executes config files as shell scripts and keeps the environment variables.
so, to change the value of `MOMMY_SWEETIE`, add the following line to your config file:
```shell
MOMMY_SWEETIE="catgirl"
```
make sure you do not put spaces around the `=`~
make sure you _do not_ put spaces around the `=`, and you _do_ put quotes (`"`) around the value~

### 👛 available settings
| variable | description | list? | default |
Expand Down Expand Up @@ -516,7 +539,7 @@ outputs `your mommy loves you`~
### ✍️ renaming the mommy executable
if you want to write `daddy npm test` instead of `mommy npm test`, you can create a symlink~

> ℹ️ if you [integrate mommy with your shell](#-shell-integration) you won't have to write `daddy` in the first place~
> ℹ️ if you [integrate mommy with your shell](#shell-integration) you won't have to write `daddy` in the first place~

mommy is installed in slightly different locations on different systems, but you can easily find where mommy is
installed with `whereis mommy`:
Expand All @@ -538,7 +561,7 @@ sudo ln -fs /usr/share/man/man1/mommy.1.gz /usr/share/man/man1/daddy.1.gz
> ℹ️ uninstalling mommy will not remove the manually created symlinks~


## 🐚 shell integration
## 🐚 shell integration<a name="shell-integration"></a> <small><sup>[top ▲](#toc)</sup></small>
instead of calling mommy for each command, you can fully integrate mommy with your shell to get mommy's output each time
you run any command.
here are some examples on how you can do that in various shells.
Expand Down Expand Up @@ -637,7 +660,7 @@ log out and back in, and mommy will appear in your shell~
</details>


## ⚗️ development
## ⚗️ development<a name="development"></a> <small><sup>[top ▲](#toc)</sup></small>
this section explains how to build mommy from source, in case you want to help with development or for any other reason~

### 🎬 run
Expand Down Expand Up @@ -790,7 +813,7 @@ surely we'll be able to figure something out together~
* your pull request should go into `dev`, not into `main`~


## 💖 acknowledgements
## 💖 acknowledgements<a name="acknowledgements"></a> <small><sup>[top ▲](#toc)</sup></small>
mommy recognises _all_ contributors, no matter the size of the contribution.
if mommy should add, remove, or change anything here, [open an issue](https://github.com/FWDekker/mommy/issues/new) or
[contact the author](https://fwdekker.com/about/)~
Expand Down
Loading