Skip to content

Commit

Permalink
Merge pull request #149 from victorperin/feat/programatic-usage
Browse files Browse the repository at this point in the history
Feat: programatic usage
  • Loading branch information
victorperin committed Jan 27, 2021
2 parents 68cadfa + 0426212 commit f018506
Show file tree
Hide file tree
Showing 16 changed files with 344 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,6 @@ tsconfig.json
*.js.map
.nycrc
.eslintignore
docs/
.github
src/
Binary file removed demo.gif
Binary file not shown.
59 changes: 59 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
qr-scanner-cli / [Exports](modules.md)

# QR Scanner CLI

[![Build Status](https://github.com/victorperin/qr-scanner-cli/workflows/pr-check/badge.svg?branch=master)](https://github.com/victorperin/qr-scanner-cli/actions?query=workflow%3Apr-check+branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/victorperin/qr-scanner-cli/badge.svg?branch=master)](https://coveralls.io/github/victorperin/qr-scanner-cli?branch=master)
[![Known Vulnerabilities](https://snyk.io/test/github/victorperin/qr-scanner-cli/badge.svg)](https://snyk.io/test/github/victorperin/qr-scanner-cli)
[![Maintainability](https://api.codeclimate.com/v1/badges/db529f4bc96d3bc44341/maintainability)](https://codeclimate.com/github/victorperin/qr-scanner-cli/maintainability)

QR Scanner CLI is a project that can resolve any QR code from an image on your desktop.

## Installation

Installation is done using the npm install command:

```
npm i -g qr-scanner-cli
```

## Usage

```
$ qrscanner <input file>
```

![New Demo Gif](https://media.giphy.com/media/u5FnaAB5tqlSJr9GuT/source.gif)

## Options

Access all available and updated options passing the `--help` argument:

```
qrscanner --help
```

A view of the options at release [v1.0.0](https://github.com/victorperin/qr-scanner-cli/releases/tag/v1.0.0):

```
--clean, -c Clear output, just print the QR Code scan result
--clipboard, -p copy the qr code value to your clipboard
--version Show installed version
--help Show this help
```

> Consider that this list may be outdated, always refer to the `help` option described above.
## Examples

```
$ qrscanner ./qrCode.jpg
╔══════════════════════════════════════════╗
║ ║
║ This message is written in a QR Code ║
║ ║
╚══════════════════════════════════════════╝
$ qrscanner ./qrCode.jpg --clean
This message is written in a QR Code
```
53 changes: 53 additions & 0 deletions docs/modules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[qr-scanner-cli](README.md) / Exports

# qr-scanner-cli

## Table of contents

### Type aliases

- [Flags](modules.md#flags)

### Functions

- [scanFromFile](modules.md#scanfromfile)

## Type aliases

### Flags

Ƭ **Flags**: { `clear?`: *boolean* ; `clipboard?`: *boolean* ; `open?`: *boolean* }

#### Type declaration:

Name | Type |
------ | ------ |
`clear?` | *boolean* |
`clipboard?` | *boolean* |
`open?` | *boolean* |

Defined in: [cli/flags.ts:13](https://github.com/victorperin/qr-scanner-cli/blob/c782de4/src/cli/flags.ts#L13)

## Functions

### scanFromFile

`Const`**scanFromFile**(`filePath`: *string*, `flags?`: [*Flags*](modules.md#flags)): *Promise*<*string*\>

This function reads a file, get it's bitmap, searches and read a qrcode from it.
```
const value = await scanFromFile('./image.jpg')
```

#### Parameters:

Name | Type | Description |
------ | ------ | ------ |
`filePath` | *string* | A file path for an image file containing a QR Code |
`flags?` | [*Flags*](modules.md#flags) | |

**Returns:** *Promise*<*string*\>

Value read from the QR Code inside the image

Defined in: [pipelines/scanFromFile.ts:17](https://github.com/victorperin/qr-scanner-cli/blob/c782de4/src/pipelines/scanFromFile.ts#L17)
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
// coverageDirectory: 'coverage',
testEnvironment: 'node',
testMatch: ['<rootDir>/tests/**/*.test.ts', '<rootDir>/src/**/*.test.ts'],
modulePathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/coverage/', '<rootDir>/.nyc_output/'],
verbose: true,
globals: {
'ts-jest': { compiler: 'ttypescript' },
Expand Down
140 changes: 140 additions & 0 deletions package-lock.json

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

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "qr-scanner-cli",
"version": "0.2.2-development",
"description": "",
"main": "index.js",
"main": "dist/index.js",
"bin": {
"qrscanner": "./qrscanner"
},
Expand All @@ -15,6 +15,7 @@
"test:all": "jest",
"test:coverage": "nyc --reporter=lcov npm run test:all && cat ./coverage/lcov.info | coveralls",
"test:diff": "jest --no-cache --passWithNoTests --collectCoverage=false --findRelatedTests",
"build:doc": "typedoc",
"build": "tsc",
"semantic-release": "semantic-release"
},
Expand Down Expand Up @@ -60,6 +61,8 @@
"ts-node": "^9.1.1",
"tsc-prog": "^2.2.1",
"ttypescript": "^1.5.12",
"typedoc": "^0.20.19",
"typedoc-plugin-markdown": "^3.4.3",
"typescript": "^4.1.3"
},
"repository": {
Expand Down
18 changes: 17 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ npm i -g qr-scanner-cli
$ qrscanner <input file>
```

![New Demo Gif](./demo.gif)
![New Demo Gif](https://media.giphy.com/media/u5FnaAB5tqlSJr9GuT/source.gif)

## Options

Expand All @@ -39,6 +39,7 @@ A view of the options at release [v1.0.0](https://github.com/victorperin/qr-scan
--version Show installed version
--help Show this help
```

> Consider that this list may be outdated, always refer to the `help` option described above.
## Examples
Expand All @@ -54,3 +55,18 @@ $ qrscanner ./qrCode.jpg
$ qrscanner ./qrCode.jpg --clean
This message is written in a QR Code
```

## Programatic Usage

You can also install this as a lib and use the programatic mode. Don't forget to read our [documentation](./docs/modules.md).

```
npm install qr-scanner-cli
```

```javascript
// some-file.js
import { scanFromFile } from 'qr-scanner-cli'

const value = await scanFromFile('./image.jpg')
```
Loading

0 comments on commit f018506

Please sign in to comment.