<commit_before># Cast

This is a Ruby gem that executes remote commands via ssh on groups of servers defined in a YAML file.

### Setup

Grab the gem:

```bash
gem install cast-ssh
```

Create your group file at ~/.cast.yml, like this:

```yaml
group1:
- host1
- host2
- host3

group2:
- host1
- host4
- host5
```

Run commands in your shell using this pattern:
```bash
cast [<flags>] <target> <command>
```

For example:
```bash
cast group1 echo test
cast group1,group2 sudo whoami
cast -s group1,host4 "df -h"
```

The output from the second command will look something like this:

```
[cast] loading groups from ~/.cast.yml
[cast] running ssh host1 'sudo whoami'
[cast] running ssh host2 'sudo whoami'
[cast] running ssh host3 'sudo whoami'
[cast] running ssh host4 'sudo whoami'
[host3] root
[host1] root
[host2] root
[host4] root
```

Note that the commands are run in parallel, so the output may be out of order.

### Options

           --serial, -s:   Execute commands serially, rather than in parallel over the group
        --delay, -d <f>:   Delay in seconds between execution of serial commands (switches to serial mode if defined)
    --groupfile, -g <s>:   YAML file of server groups (default: ~/.cast.yml)
             --list, -l:   Print out contents of groupfile without executing command
         --clusters, -c:   Print out only groupnames without executing command
          --ssh, -h <s>:   SSH command to run (default: ssh)
          --version, -v:   Print version and exit
             --help, -e:   Show this message

### API

You can also access the same functionality from within Ruby.

To include Cast in your code do:
```ruby
require 'cast'
```

The following methods are available:

* __Cast::remote__ host, cmd

  Run a remote command on the given host, sending output to stdout.

* __Cast::local__ cmd, options = {} -> int

  Run a command locally, printing stdout and stderr from the command. Returns the process' return value.

  You can use the following options:
  ```
  :ensure              - Raise exceptions if the command returns a non-zero error code.<commit_msg>Update readme with current options<commit_after># Cast

This is a Ruby gem that executes remote commands via ssh on groups of servers defined in a YAML file.

### Setup

Grab the gem:

```bash
gem install cast-ssh
```

Create your group file at ~/.cast.yml, like this:

```yaml
group1:
- host1
- host2
- host3

group2:
- host1
- host4
- host5
```

Run commands in your shell using this pattern:
```bash
cast [<flags>] <target> <command>
```

For example:
```bash
cast group1 echo test
cast group1,group2 sudo whoami
cast -s group1,host4 "df -h"
```

The output from the second command will look something like this:

```
[cast] loading groups from ~/.cast.yml
[cast] running ssh host1 'sudo whoami'
[cast] running ssh host2 'sudo whoami'
[cast] running ssh host3 'sudo whoami'
[cast] running ssh host4 'sudo whoami'
[host3] root
[host1] root
[host2] root
[host4] root
```

Note that the commands are run in parallel, so the output may be out of order.

### Options

             --serial, -s:   Execute commands serially, rather than in parallel over the group
          --delay, -d <f>:   Delay in seconds between execution of serial commands (switches to serial mode if defined)
      --groupfile, -g <s>:   YAML file of server groups (default: ~/.cast.yml)
               --list, -l:   Print out contents of groupfile without executing command
           --clusters, -c:   Print out only groupnames without executing command
            --ssh, -h <s>:   SSH command to run (default: ssh)
             --strict, -t:   Return a non-zero exit code if ANY of the ssh commands exit non-zero
  --controlfolder, -o <s>:   Path to look in for any ControlMaster tunnels (default: ~/.ssh/)
            --version, -v:   Print version and exit
               --help, -e:   Show this message


### API

You can also access the same functionality from within Ruby.

To include Cast in your code do:
```ruby
require 'cast'
```

The following methods are available:

* __Cast::remote__ host, cmd

  Run a remote command on the given host, sending output to stdout.

* __Cast::local__ cmd, options = {} -> int

  Run a command locally, printing stdout and stderr from the command. Returns the process' return value.

  You can use the following options:
  ```
  :ensure              - Raise exceptions if the command returns a non-zero error code.
{'fraction_non_alphanumeric': 0.09761045987376014, 'fraction_numerical': 0.009467989179440937, 'mean_word_length': 3.026315789473684, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5463614', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1282, 'n_words': 625}