Repository: sindresorhus/do-not-disturb-cli Branch: main Commit: 7c36c3caa820 Files: 11 Total size: 4.1 KB Directory structure: gitextract_rpl3d0o7/ ├── .editorconfig ├── .gitattributes ├── .github/ │ └── workflows/ │ └── main.yml ├── .gitignore ├── .npmrc ├── cli.js ├── dnd.js ├── license ├── package.json ├── readme.md └── test.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .editorconfig ================================================ root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.yml] indent_style = space indent_size = 2 ================================================ FILE: .gitattributes ================================================ * text=auto eol=lf ================================================ FILE: .github/workflows/main.yml ================================================ name: CI on: - push - pull_request jobs: test: name: Node.js ${{ matrix.node-version }} runs-on: macos-latest strategy: fail-fast: false matrix: node-version: - 16 steps: - uses: actions/checkout@v2 - uses: actions/setup-node@v2 with: node-version: ${{ matrix.node-version }} - run: npm install - run: npm test ================================================ FILE: .gitignore ================================================ node_modules yarn.lock ================================================ FILE: .npmrc ================================================ package-lock=false ================================================ FILE: cli.js ================================================ #!/usr/bin/env node import meow from 'meow'; import doNotDisturb from '@sindresorhus/do-not-disturb'; const cli = meow(` Usage $ do-not-disturb Commands on off toggle status Examples $ do-not-disturb on $ do-not-disturb status on Use \`$ dnd\` to quickly toggle `, { importMeta: import.meta, }); const [command] = cli.input; (async () => { switch (command) { case 'on': await doNotDisturb.enable(); break; case 'off': await doNotDisturb.disable(); break; case 'toggle': await doNotDisturb.toggle(); break; case 'status': console.log(await doNotDisturb.isEnabled() ? 'on' : 'off'); break; default: cli.showHelp(); } })(); ================================================ FILE: dnd.js ================================================ #!/usr/bin/env node import meow from 'meow'; import doNotDisturb from '@sindresorhus/do-not-disturb'; meow(` Usage $ dnd Toggle "Do Not Disturb" `, { importMeta: import.meta, }); doNotDisturb.toggle(); ================================================ FILE: license ================================================ MIT License Copyright (c) Sindre Sorhus (https://sindresorhus.com) 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. ================================================ FILE: package.json ================================================ { "name": "do-not-disturb-cli", "version": "1.0.0", "description": "Control the macOS `Do Not Disturb` feature from the command-line", "license": "MIT", "repository": "sindresorhus/do-not-disturb-cli", "funding": "https://github.com/sponsors/sindresorhus", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "https://sindresorhus.com" }, "type": "module", "bin": { "do-not-disturb": "./cli.js", "dnd": "./dnd.js" }, "engines": { "node": "^12.20.0 || ^14.13.1 || >=16.0.0" }, "scripts": { "test": "xo && ava" }, "files": [ "cli.js", "dnd.js" ], "keywords": [ "cli-app", "cli", "macos", "swift", "notifications" ], "dependencies": { "@sindresorhus/do-not-disturb": "^2.0.0", "meow": "^10.1.1" }, "devDependencies": { "ava": "^3.15.0", "execa": "^5.1.1", "xo": "^0.45.0" } } ================================================ FILE: readme.md ================================================ # do-not-disturb-cli > Control the macOS `Do Not Disturb` feature from the command-line ## Install ```sh npm install --global do-not-disturb-cli ``` ## Usage ``` $ do-not-disturb --help Usage $ do-not-disturb Commands on off toggle status Examples $ do-not-disturb on $ do-not-disturb status on Use `$ dnd` to quickly toggle ``` ## Related - [do-not-disturb](https://github.com/sindresorhus/do-not-disturb) - API for this module ================================================ FILE: test.js ================================================ import test from 'ava'; import execa from 'execa'; test('main', async t => { const {stdout} = await execa('./cli.js', ['status']); t.regex(stdout, /on|off/); });