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

CLI flags #51

Merged
merged 3 commits into from
Sep 10, 2022
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
55 changes: 51 additions & 4 deletions .github/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ yarn add validatees
pnpm install validatees
```

To check if you have the **latest version**, run using `npx`✅:

```bash
# npx
npx validatees-cli --check
```

## Usage

```js
Expand All @@ -44,7 +51,11 @@ import validatees from "validatees";

- [VListener](#vlistener)
- [parameters](#parameters)
- [options](#options1)
- [options](#options-vlistener)
- [CLI](#cli)
- [installation](#installation-cli)
- [usage](#usage-cli)
- [options](#options-cli)
- [types](#types)
- [isFalsy](#isfalsy)
- [isFalsyExtended](#isfalsyextended)
Expand All @@ -56,7 +67,7 @@ import validatees from "validatees";
- [matchers](#matchers)
- [isValidEmail](#isvalidemail)
- [isValidPassword](#isvalidpassword)
- [options](#options2)
- [options](#options-isvalidpassword)
- [isValidUrl](#isvalidurl)
- [isUnique](#isunique)
- [isSoftMatch](#issoftmatch)
Expand All @@ -73,7 +84,7 @@ Adding validation over your array before your program starts.
Use validatees `isTruthy` or `isFalsy` for example.
<!-- To Be Extended with callback array to validate even more! -->

#### **options1**:
#### **options-vlistener**:

- `strict`: `boolean`, default: `false`, strict mode; skip push if validation fails in 1 or more items.
- `condition`: `boolean`, default: `true`, condition to validate; check if callback with `condition` is met.
Expand Down Expand Up @@ -112,6 +123,42 @@ arr2.push({}); // can now be pushed again.
console.log(arr2); // [{ a: 1 }, { b: 2 }, {}]
```

### CLI

#### **installation-cli**:

To use the CLI, you can use `npx` or install it globally using `npm` or `yarn`:

```bash
# npm
npm install -g validatees
# yarn
yarn global add validatees
```

#### **usage-cli**:

To use the CLI, run `validatees-cli` in your terminal:
You do not need to install the package when using `npx`.

```bash
# npx
npx validatees-cli <args>
# npm & yarn
validatees-cli <args>
```

#### **options-cli**:

- `--help, -help, --h, -h`: show help. </br>
`validatees-cli --help` or `validatees-cli -h` or `validatees-cli --h`
- Can be used after each of the following flags to show help for that flag.
- Or can be used to display all the flags and their description.
- `--version, -version, --v, -v`: show the current installed version.
- `--check, -check, --c, -c`: check if the installed version is up to date with the latest version.
- `--exit, -exit, --e, -e`: exit the process after the command execution, default: `false`.
<!-- - `--update, -update, --u, -u`: update to the latest version. -->

### Types

Type checking can be difficult, but with `validatees` types, it's easy.
Expand Down Expand Up @@ -293,7 +340,7 @@ isValidEmail(123); // throws error

Check if value is a valid password.

##### **options2**:
##### **options-isvalidpassword**:

- `minLength`: number, default `8`
- `maxLength`: number, default `32`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
node-version: 16.x
- name: run version check
run: |
node check-version
npm run cli:check:ci
# if this step fails, the workflow will stop
validatees-suite:
runs-on: ubuntu-latest
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.7.0

- You are now able to run CLI commands using npx.
- Learned a bit about how to use `npx` and how it relates to the package itself.
- Updated the docs accordingly.
- Updated the devDependencies to the latest versions.
- CLI: Added a `--version` flag to the CLI.
- CLI: Added a `--help` flag to the CLI.
- CLI: Added a `--exit` flag to the CLI.
- CLI: Added a `--check` flag to the CLI.

## 0.6.7

- Commit to try to fix `npx validatees-version-check`.
Expand Down
60 changes: 0 additions & 60 deletions check-version.js

This file was deleted.

Loading