Skip to content

Commit

Permalink
Add 'Examples' section to README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
deniskovalchuk committed Sep 4, 2023
1 parent 557094e commit b3f0017
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,13 @@

A cross-platform FTP client library based on Boost.Asio.

```c++
#include <iostream>
#include <sstream>
#include <ftp/ftp.hpp>

int main(int argc, char *argv[])
{
ftp::client client;

client.connect("ftp.freebsd.org", 21, "anonymous");

std::ostringstream oss;

client.download_file(ftp::ostream_adapter(oss), "pub/FreeBSD/README.TXT");

std::cout << oss.str();

client.disconnect();

return 0;
}
```
![Session Example](doc/session-example.png)

## Table of contents

1. [Overview](#overview)
1. [Features](#features)
1. [Examples](#examples)
1. [Prerequisites](#prerequisites)
1. [Build and Run](#build-and-run)
1. [Command-Line Client](#command-line-client)
Expand Down Expand Up @@ -78,6 +58,31 @@ reverse conversion.
- Supports active and passive transfer modes.
- Supports ASCII and binary transfer types.

## Examples

```c++
#include <iostream>
#include <sstream>
#include <ftp/ftp.hpp>

int main(int argc, char *argv[])
{
ftp::client client;

client.connect("ftp.freebsd.org", 21, "anonymous");

std::ostringstream oss;

client.download_file(ftp::ostream_adapter(oss), "pub/FreeBSD/README.TXT");

std::cout << oss.str();

client.disconnect();

return 0;
}
```
## Prerequisites
- A C++17-compliant compiler
Expand Down Expand Up @@ -136,8 +141,6 @@ ctest -V

## Command-Line Client

![Session Example](doc/session-example.png)

The supplied command-line client supports the following commands:

1. open hostname [ port ] - connect to ftp server
Expand Down

0 comments on commit b3f0017

Please sign in to comment.