Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EXAMPLES.md corrections #527

Merged
merged 6 commits into from
Jan 5, 2024
21 changes: 8 additions & 13 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ on hosts do |host|
end
```

**Note:** The `upload!()` method doesn't honor the values of `as()` etc, this
will be improved as the library matures, but we're not there yet.

## Upload a file from a stream

```ruby
Expand All @@ -148,9 +145,6 @@ end
This spares one from having to figure out the correct escaping sequences for
something like "echo(:cat, '...?...', '> /etc/sudoers.d/yolo')".

**Note:** The `upload!()` method doesn't honor the values of `within()`, `as()`
etc, this will be improved as the library matures, but we're not there yet.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This (and the above) appeared to be inaccurate based on my testing of #524.


## Upload a directory of files

```ruby
Expand All @@ -160,7 +154,8 @@ end
```

In this case the `recursive: true` option mirrors the same options which are
available to [`Net::{SCP,SFTP}`](http://net-ssh.github.io/net-scp/).
available to [`Net::SCP`](https://github.com/net-ssh/net-scp) and
[`Net::SFTP`](https://github.com/net-ssh/net-sftp).

## Set the upload/download method (SCP or SFTP).

Expand Down Expand Up @@ -252,16 +247,16 @@ end

```ruby
# The default format is pretty, which outputs colored text
SSHKit.config.format = :pretty
SSHKit.config.use_format :pretty
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These appeared to have never been updated in 2cb6326.


# Text with no coloring
SSHKit.config.format = :simpletext
SSHKit.config.use_format :simpletext

# Red / Green dots for each completed step
SSHKit.config.format = :dot
SSHKit.config.use_format :dot

# No output
SSHKit.config.format = :blackhole
SSHKit.config.use_format :blackhole
```

## Implement a dirt-simple formatter class
Expand All @@ -271,7 +266,7 @@ module SSHKit
module Formatter
class MyFormatter < SSHKit::Formatter::Abstract
def write(obj)
case obj.is_a? SSHKit::Command
if obj.is_a? SSHKit::Command
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least with Ruby 3.2.2, this case produced an error:

SyntaxError: unexpected `end', expecting `when'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

# Do something here, see the SSHKit::Command documentation
end
end
Expand All @@ -280,7 +275,7 @@ module SSHKit
end

# If your formatter is defined in the SSHKit::Formatter module configure with the format option:
SSHKit.config.format = :myformatter
SSHKit.config.use_format :myformatter

# Or configure the output directly
SSHKit.config.output = MyFormatter.new($stdout)
Expand Down