TARGETS
  • Read Me
  • Introduction
    • Motivation
    • Project Goals
    • What is Targets?
    • Who is Targets for?
    • Common Use Cases
    • What is a "target"?
    • What is a "composition"?
    • What is an "operation"?
    • What is a "spec"?
    • What does a Targets implementation look like?
    • Background
  • Learn Targets
    • Hello World
    • Config - Part 1
    • Config - Part 2
    • Bindings
    • Composition
    • Loaders
    • Project Structure
    • More Examples
  • Reference
    • System Requirements
    • Installation
    • Configuration
    • Settings
    • Global Store
    • Scheduler
    • Operations
      • Binding Operations
      • Predicating Operations
      • Debugging Operations
    • TTY Mode
Powered by GitBook
On this page
  1. Learn Targets

Project Structure

You can structure your project however you like, however, here is some basic guidance you might find useful.

If you define all your targets in a ./targets directory like so:

./mycli
  └─┬─┬─ targets/
    │ ├─── ip.js
    │ ├─── memory.js
    │ └─── tcpdump.js
    ├─ package.json
    ├─ index.js
    └─ .myclirc

Then, in ./index.js you just need to include the following to auto register any new target file modules.

#!/usr/bin/env node
'use strict';

const Targets = require('targets');

Targets.load('./targets/**');

Targets({ name: 'mycli', targets });

With this structure in place, so long as each file module inside the ./targets directory exports a function, the filename (minus the extension) will become the target's name.

PreviousLoadersNextMore Examples

Last updated 6 years ago