Skip to content
Matteo Figus edited this page Mar 12, 2017 · 19 revisions

Install the cli

To install cli, you should type:

npm install oc -g

Configure autocomplete

Autocomplete is supported for Mac and Linux.

To enable it in zsh, you should type:

echo '. <(oc completion)' >> .zshrc

To enable it in bash, you should type:

oc completion >> ~/.bashrc

or

oc completion >> ~/.bash_profile

After enabling autocomplete you should reload the shell.

Commands

When you type oc in your command line:

oc

you should get the list of available commands:

Usage: oc <command> [options]

Commands:
  dev <dirPath> [port] [baseUrl]                Runs a local oc test registry in order to develop and test components
  init <componentName> [templateType]           Creates a new empty component [of either jade or handlebars template
                                                type] in the current folder
  mock <targetType> <targetName> <targetValue>  Allows to mock configuration in order to facilitate local development
  preview <componentHref>                       Runs a test page consuming a component
  publish <componentPath>                       Publish a component
  registry <command>                            Manages oc registries in the current project
  completion                                    generate bash completion script

Options:
  -h, --help  Show help                                                                                        [boolean]
  --version   Show version number                                                                              [boolean]

Hint: Run -h with any command to show the help

##dev Runs a local oc test registry in order to develop and test components

Usage: src/oc-cli.js dev <dirName> [port] [baseUrl] [options]

Options:
  -h, --help             Show help                                                                                                                                                                 [boolean]
  --version              Show version number                                                                                                                                                       [boolean]
  --fallbackRegistryUrl  Url to another registry which will be used by dev registry when component cannot be found in local registry
  --hotReloading         Enables hot reloading. Note: when hot reloading is set to true, each request to the component will make the registry to create a new instance for the javascript closures to be
                         loaded, while when false the instance will be recycled between components executions                                                                      [boolean] [default: true]
  --verbose              Verbosity                                                                                                                                                [boolean] [default: false]

Examples:
  src/oc-cli.js dev ../all-components 3001 127.0.0.1:3001
  --fallbackRegistryUrl=http://anotherhost:anotherport/

Parameters:

Name Description Choices
dirName The name of the directory to watch, where the components are stored
port The port where to start a local oc instance. Default 3000
baseUrl The base url the component is hosted from. Default http://localhost:port/

##init Creates a new empty component in the current folder

Usage: oc init <componentName> [templateType]

Examples:
  oc init test-component jade

Parameters:

Name Description Choices
componentName The name of the component to create
templateType The component's template type. Default handlebars jade,handlebars

##mock Allows to mock configuration in order to facilitate local development

Usage: oc mock <targetType> <targetName> <targetValue>

Examples:
  oc mock plugin hash "always-returned-value"  Creates static mock for a "hash" plugin which always returns
                                               "always-returned-value" value

Parameters:

Name Description Choices
targetType The type of item to mock plugin
targetName The item to mock
targetValue The mocked value (static plugin) or the file to read (dynamic plugin)

##preview Runs a test page consuming a component

Usage: oc preview <componentHref>

Examples:
  oc preview "http://localhost:3000/my-new-component/1.0.0/?param1=hello&name=Arthur"

Parameters:

Name Description Choices
componentHref The name of the component to preview

##publish Publish a component

Usage: oc publish <componentPath> [options]

Options:
  --password  password used to authenticate when publishing to registry
  --username  username used to authenticate when publishing to registry

Examples:
  oc publish my-new-component/

Parameters:

Name Description Choices
componentPath The path of the component to publish

##registry Shows, adds, removes oc registries to the current project

Usage: oc registry <command>

Commands:
  add <registryUrl>     Adds oc registries to the current project
  ls                    Shows oc registries added to the current project
  remove <registryUrl>  Removes oc registries from the current project

Examples:
  oc registry add http://my-registry.in.my.domain/
  oc registry ls
  oc registry remove http://my-registry.in.my.domain/

Parameters:

Name Description Choices
registryUrl url of registry
Clone this wiki locally