• Stars
    star
    276
  • Rank 149,319 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 11 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Beautiful UI for showing tasks running on the command line.

Observatory Build Status

Beautiful UI for showing tasks running on the command line.

Purpose

Instead of just logging long running tasks to the console, give your users a simple status dashboard.

observatory

Installation

$ npm install observatory

Examples

node ./examples/buzzwords.js

An example using fake data that tries to look like a real-world usage.

node ./examples/long-line.js

An example of what happens when text is so long it needs to wrap to another line.

Usage Example

var observatory = require('observatory');

//add a task to display
var task = observatory.add('Install packages...');

//while working on the task, update the status
task.running('Copying Files');

//optionally give details
task.details(percent + '% ' + filename);

//chain commands
task.status('Compressing Images')
    .details(directoryName);

//when complete
task.done('Finished!');

//or if it failed
task.fail('Ooops');

Terminology

[Test Runner] Running tests on Safari  Running Now  50%  CSS3 Tests
⇧ prefix      ⇧ description            ⇧ status     ⇧ details

API

observatory.add(description)

description string Required description.
returns a new task

Adds a task to the console. This method returns a task object, you should store it in a variable so you can use it for the methods bellow.

var copyFilesTask = observatory.add('Copy files');

Task Methods

All task methods return the task object so that you can chain functions, such as task.done().status('Installed!');.

task.status(statusLabel)

statusLabel string Set the status value.

Displays a short message to the right of the description. Use it to show users in a word or two that suggests what is happening.

Examples:

  • task.status('Downloading');
  • task.status('Running');
  • task.status('Complete');

task.details(detailsLabel)

detailsLabel string Set the details value.

Optional provide details about what's happening, such as file names, urls, tests names.

Examples:

  • task.details('Copying var/tmp/whatever to var/whater/tmp');
  • task.details('Compressing bigimage.png');
  • task.details('Testing services');

task.done(statusLabel)

statusLabel string Set the status value. Default: ✓ Done.

  • task.done();
  • task.done('Compressed!')

task.fail(statusLabel)

statusLabel string Set the status value. Default: ✗ Failed.

  • task.fail();
  • `task.fail('Disconnected');

Override Settings

observatory.settings(settingsObject)

Tweak how tasks are rendered.

settingsObject

  • width Integer, width in characters of the description and status area. This is used to right justify the status. Default is 55.
  • prefix Sting, Text to prepend each line. Default is ' ⫸ '.
  • write Function(content). Writes the content to the output. Defaults to process.stdout.write.
  • formatStatus Function(statusLabel, STATE)

returns observatory so you can use it on the require statement.

var observatory = require('observatory').settings({
  prefix: '[bower] '.white
});

observatory.STATE

A constant for the different states. Only useful if you need to change formatStatus above.

The values:

  • observatory.STATE.active Defaults to using default console color.
  • observatory.STATE.done Defaults to using green.
  • observatory.STATE.fail Defaults to using red.

Acknowledgements

Inspiration

  • My coworker Nick at Opower for inspiring the need for this library.
  • Bower, inspiring the clean layout.
  • Inqurire.js, for showing console apps can have a nice UI.

Release History

  • 15 October 2015 - 1.0.0 - Update dependencies, fix tests and bugs thanks to @rstacruz.
  • 20 October 2013 - 0.1.0 - Some cleanup thanks to @nickheiner, new write method.
  • 15 October 2013 - 0.0.1 - First version

License

Copyright (c) 2015 Dylan Greene
Licensed under the MIT license.

More Repositories

1

npm-check

Check for outdated, incorrect, and unused dependencies.
JavaScript
6,553
star
2

shortid

Short id generator. Url-friendly. Non-predictable. Cluster-compatible.
JavaScript
5,736
star
3

node-rss

RSS feed generator for Node.
JavaScript
995
star
4

grunt-notify

Automatic Notifications when Grunt tasks fail.
JavaScript
921
star
5

grunt-prompt

Add interactive UI to your Gruntfile such as lists, checkboxes, text input with filtering, and password fields, all on the command line.
JavaScript
368
star
6

node-xml

Fast and simple Javascript-based XML generator/builder for Node projects.
JavaScript
274
star
7

changelog

Finally see what's changed when you do npm update. Changelog generates a changelog for npm modules and github repos.
JavaScript
239
star
8

space-hogs

Discover surprisingly large directories from the command line.
JavaScript
161
star
9

opowerjobs

Node.js site using Express and Connect.
JavaScript
61
star
10

logging

Lightweight informative modern console logging.
JavaScript
54
star
11

anthology

List of modules for any npm user, plus number of downloads and github stars.
JavaScript
46
star
12

captionbot

Get captions for image using Microsoft's CaptionBot
JavaScript
41
star
13

grunt-attention

Display attention-grabbing messages in the terminal.
JavaScript
26
star
14

jira-improved

Improves the Jira Agile board by showing the Epic name in the cards and hiding the Done column if you use a quick filter to hide tickets in that column.
JavaScript
24
star
15

node-atom

DEPRECATED - NOT MAINTAINED
JavaScript
20
star
16

what-dog

Get the breed of a dog from an image using Microsoft's what-dog
JavaScript
15
star
17

grunt-cat

Echo a file to the terminal. Works with text, figlets, ascii art, and full-color ansi.
JavaScript
14
star
18

random-puppy

Get a random puppy image url.
JavaScript
13
star
19

jobvite

DEPRECATED ----- Jobvite API for Node
JavaScript
12
star
20

source-map-diff

Compare source maps with cli and web output
TypeScript
7
star
21

flowdock-refined

DEPRECATED - Flowdock desktop app custom UI
CSS
5
star
22

...

really, this is a valid project name?
2
star
23

dotfiles

Vim Script
2
star
24

lean

Simple in-memory data store to lean on. Helpful when you don't need a couch.
JavaScript
2
star
25

jquery-tooltips

Easy to use image-free HTML5 tooltips for jQuery 1.5.2+.
JavaScript
2
star
26

grunt-templates-dylang

Templates for grunt-readme that dylang will be using across multiple projects.
JavaScript
1
star
27

dotconfig

My custom terminal colors, bash-it prompt, intellij and webstorm settings, etc
Shell
1
star
28

dylang.github.com

Everything you need to know about me.
1
star