diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a9be566 --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.vscode/ + +# Created by https://www.gitignore.io/api/rust +# Edit at https://www.gitignore.io/?templates=rust + +### Rust ### +# Generated by Cargo +# will have compiled files and executables +/target/ + +# These are backup files generated by rustfmt +**/*.rs.bk + +# End of https://www.gitignore.io/api/rust diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..be5737d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +language: rust +os: linux +dist: trusty +cache: cargo +rust: + - stable + - beta + - nightly +jobs: + allow_failures: + - rust: nightly +before_cache: | + if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then + cargo install cargo-tarpaulin + fi +script: + - cargo clean + - cargo build --verbose --all + - cargo test --lib --verbose -- --test-threads 1 +after_success: | + if [[ "$TRAVIS_RUST_VERSION" == stable ]]; then + cargo tarpaulin --out Xml --ignore-tests -- --test-threads 1 + bash <(curl -s https://codecov.io/bash) + fi +deploy: + provider: cargo + token: + secure: kbZJ1CW2+QAk2u4UWOJehF0gliR/l5JeVmewf/eXKnGttdcJrkIQ70D0F+Rhu4/ZJOlvNpTFLpt3MIKyL3LnjbwO9Q4pDsCjSCRnswz/UkRfzoaY1sL07sesAdEnGCDTwdSEueL1dpmlC46wPbe/7ErnPOxFiMgtR+nX6X6O8u8shSs2T2B5ltnatHo9+pnY28u+EDg4kzdGkP63kt66x5npkNVD3IXuRXIh02YAYzuUnZbMm7vmbg5DdefyYfYvCaHW3udL344iBtxDybYlw+C+TSlEUQ8o/lIC9dXg7RFgsHrXgiwo5S9qyUr+Vuq0VdYQe5qW885hOqxVLBWyGImka/gRFcRRfgoD2WUIF1WWvivqV2iDXF6KzYG4iikPlbbF2+zssfVkxCAQUILn7nFxxKtQzeVfogP2tW1U+UfmIyRdnpxRuV7SpfvUkNhYBQWG9Qv1hJ0gT4EH5HxKsyo3iRYF3Yfw6yRtzsjk0BAmqKz5sKNjubyd7y/s4uc61KR2xZnaw7ipIZ/NABLHqbahTPdreEW9SnysQOuWCgciTyMyiTMm08vPxIEDi770VXcvgrr662xTYJvb0+7yPcuL0uv2i9nfdl22/P9IpaGCSLl3HnUp0G8xxdcSD6vZ/6eMDZmye6Nlorg4RKvwVcpHzp8HaQ5lDpfKKmDo2GU= + on: + tags: true diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..dea0512 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,76 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, sex characteristics, gender identity and expression, +level of experience, education, socio-economic status, nationality, personal +appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at christian.visintin1997@gmail.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see + diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..db3b752 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,7 @@ +# Contributing + +- [Contributing](#contributing) + +--- + +TODO diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..98e07ed --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,329 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "cassowary" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df8670b8c7b9dae1793364eafadf7239c40d669904660c5960d74cfd80b46a53" + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cloudabi" +version = "0.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" +dependencies = [ + "bitflags", +] + +[[package]] +name = "cloudabi" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" +dependencies = [ + "bitflags", +] + +[[package]] +name = "crossterm" +version = "0.17.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f4919d60f26ae233e14233cc39746c8c8bb8cd7b05840ace83604917b51b6c7" +dependencies = [ + "bitflags", + "crossterm_winapi", + "lazy_static", + "libc", + "mio", + "parking_lot 0.10.2", + "signal-hook", + "winapi", +] + +[[package]] +name = "crossterm" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e86d73f2a0b407b5768d10a8c720cf5d2df49a9efc10ca09176d201ead4b7fb" +dependencies = [ + "bitflags", + "crossterm_winapi", + "lazy_static", + "libc", + "mio", + "parking_lot 0.11.0", + "signal-hook", + "winapi", +] + +[[package]] +name = "crossterm_winapi" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2265c3f8e080075d9b6417aa72293fc71662f34b4af2612d8d1b074d29510db" +dependencies = [ + "winapi", +] + +[[package]] +name = "getopts" +version = "0.2.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "instant" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" + +[[package]] +name = "lock_api" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "lock_api" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "mio" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8962c171f57fcfffa53f4df1bb15ec4c8cf26a7569459c9ceb62d94aab0d9584" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07b88fb9795d4d36d62a012dfbf49a8f5cf12751f36d31a9dbe66d528e58979e" +dependencies = [ + "socket2", + "winapi", +] + +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + +[[package]] +name = "parking_lot" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" +dependencies = [ + "lock_api 0.3.4", + "parking_lot_core 0.7.2", +] + +[[package]] +name = "parking_lot" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" +dependencies = [ + "instant", + "lock_api 0.4.1", + "parking_lot_core 0.8.0", +] + +[[package]] +name = "parking_lot_core" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi 0.0.3", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi 0.1.0", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "signal-hook" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "604508c1418b99dfe1925ca9224829bb2a8a9a04dda655cc01fcad46f4ab05ed" +dependencies = [ + "libc", + "mio", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce32ea0c6c56d5eacaeb814fbed9960547021d3edd010ded1425f180536b20ab" +dependencies = [ + "libc", +] + +[[package]] +name = "smallvec" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" + +[[package]] +name = "socket2" +version = "0.3.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1fa70dc5c8104ec096f4fe7ede7a221d35ae13dcd19ba1ad9a81d2cab9a1c44" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "redox_syscall", + "winapi", +] + +[[package]] +name = "termscp" +version = "0.1.0" +dependencies = [ + "crossterm 0.18.2", + "getopts", + "tui", +] + +[[package]] +name = "tui" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2eaeee894a1e9b90f80aa466fe59154fdb471980b5e104d8836fcea309ae17e" +dependencies = [ + "bitflags", + "cassowary", + "crossterm 0.17.7", + "unicode-segmentation", + "unicode-width", +] + +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..2cdd272 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "termscp" +version = "0.1.0" +authors = ["Christian Visintin"] +edition = "2018" +license = "GPL-3.0" +keywords = ["scp-client", "sftp-client", "ftp-client", "winscp", "command-line-utility"] +categories = ["command-line-utilities"] +description = "TermSCP is a SCP/SFTP/FTPS client for command line with an integrated UI to explore the remote file system. Basically WinSCP on a terminal." +homepage = "https://github.com/ChristianVisintin/TermSCP" +repository = "https://github.com/ChristianVisintin/TermSCP" +documentation = "https://docs.rs/termscp" +readme = "README.md" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +crossterm = "0.18.2" +getopts = "0.2.21" +tui = { version = "0.12.0", features = ["crossterm"], default-features = false } + +[[bin]] +name = "termscp" +path = "src/main.rs" diff --git a/LICENSE b/LICENSE index f288702..e075f67 100644 --- a/LICENSE +++ b/LICENSE @@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - - Copyright (C) + TermSCP + Copyright (C) 2020 Christian Visintin This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + TermSCP Copyright (C) 2020 Christian Visintin This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md new file mode 100644 index 0000000..3bef1d1 --- /dev/null +++ b/README.md @@ -0,0 +1,109 @@ +# Pyc + +[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0) [![Stars](https://img.shields.io/github/stars/ChristianVisintin/TermSCP.svg)](https://github.com/ChristianVisintin/TermSCP) [![Issues](https://img.shields.io/github/issues/ChristianVisintin/TermSCP.svg)](https://github.com/ChristianVisintin/TermSCP/issues) [![Crates.io](https://img.shields.io/badge/crates.io-v0.1.0-orange.svg)](https://crates.io/crates/termscp) [![Build](https://api.travis-ci.org/ChristianVisintin/TermSCP.svg?branch=master)](https://travis-ci.org/ChristianVisintin/TermSCP) [![codecov](https://codecov.io/gh/ChristianVisintin/TermSCP/branch/master/graph/badge.svg)](https://codecov.io/gh/ChristianVisintin/TermSCP) + +~ Basically, WinSCP on a terminal ~ +Developed by Christian Visintin +Current version: 0.1.0 (??/??/2020) + +⚠ This project is **still under development**; installation instructions won't work until release ⚠ + +--- + +- [Pyc](#pyc) + - [About TermSCP](#about-termscp) + - [Why TermSCP](#why-termscp) + - [Features](#features) + - [Installation](#installation) + - [Cargo](#cargo) + - [Deb / Rpm](#deb--rpm) + - [Usage](#usage) + - [Documentation](#documentation) + - [Known issues](#known-issues) + - [Upcoming Features](#upcoming-features) + - [Contributions](#contributions) + - [Changelog](#changelog) + - [License](#license) + +--- + +## About TermSCP + +TermSCP is basically a porting of WinSCP to terminal. So basically is a terminal tool with an UI to connect to a remote server to retrieve and upload files. It works both on Linux, MacOS and Windows (TODO: double check) and supports SCP, SFTP and FTPS. + +### Why TermSCP + +It happens very often to me when using SCP at work to forget the path of a file on a remote machine, which forces me then to connect through SSH, gather the file path and finally download it through SCP. I could use WinSCP, but I use Linux and I pratically use the terminal for everything, so I wanted something like WinSCP on my terminal. + +## Features + +- Different communication protocols + - SCP + - SFTP + - FTPS +- Practical user interface to explore the remote machine file system and to select the files to upload and download +- Written in Rust +- Easy to extend with new protocols + +## Installation + +If you're considering to install TermSCP I want to thank you 💛! I hope this project can be useful for you! +If you want to contribute to this project, don't forget to check out our contribute guide. [Read More](CONTRIBUTING.md) + +### Cargo + +```sh +# Install termscp through cargo +cargo install termscp +``` + +### Deb / Rpm + +Coming soon + +### Usage + +TermSCP can be started with the following options: + +- `-v, --version` Print version info +- `-h, --help` Print help page + +## Documentation + +The developer documentation can be found on Rust Docs at + +--- + +## Known issues + +TODO: + +--- + +## Upcoming Features + +TODO: + +--- + +## Contributions + +Contributions are welcome! 😉 + +If you think you can contribute to TermSCP, please follow [TermSCP's contributions guide](CONTRIBUTING.md) + +## Changelog + +See the enire changelog [HERE](CHANGELOG.md) + +--- + +## License + +Licensed under the GNU GPLv3 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at + + + +Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + +You can read the entire license [HERE](LICENSE) diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..7d9375a --- /dev/null +++ b/codecov.yml @@ -0,0 +1,2 @@ +ignore: + - src/main.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..8129ad6 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,20 @@ +/* +* +* Copyright (C) 2020 Christian Visintin - christian.visintin1997@gmail.com +* +* This file is part of "TermSCP" +* +* TermSCP is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* TermSCP is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with TermSCP. If not, see . +* +*/ diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..02c0898 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,75 @@ +/* +* +* Copyright (C) 2020 Christian Visintin - christian.visintin1997@gmail.com +* +* This file is part of "TermSCP" +* +* TermSCP is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* TermSCP is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with TermSCP. If not, see . +* +*/ + +const TERMSCP_VERSION: &'static str = env!("CARGO_PKG_VERSION"); +const TERMSCP_AUTHORS: &'static str = env!("CARGO_PKG_AUTHORS"); + +// Crates +extern crate getopts; + +// External libs +use getopts::Options; +use std::env; + +/// ### print_usage +/// +/// Print usage + +fn print_usage(opts: Options) { + let brief = format!("Usage: termscp [Options]... Remote"); + print!("{}", opts.usage(&brief)); +} + +fn main() { + let args: Vec = env::args().collect(); + //Program CLI options + // TODO: insert opts here + //Process options + let mut opts = Options::new(); + // opts.optopt("c", "command", "Specify command to run. Shell returns after running the command", ""); + // opts.optopt("C", "config", "Specify YAML configuration file", ""); + // opts.optopt("l", "lang", "Specify shell language", ""); + // opts.optopt("s", "shell", "Force the shell binary path", ""); + opts.optflag("v", "version", ""); + opts.optflag("h", "help", "Print this menu"); + let matches = match opts.parse(&args[1..]) { + Ok(m) => m, + Err(f) => { + println!("{}", f.to_string()); + std::process::exit(255); + } + }; + // Help + if matches.opt_present("h") { + print_usage(opts); + std::process::exit(255); + } + // Version + if matches.opt_present("v") { + eprintln!( + "TermSCP - {} - Developed by {}", + TERMSCP_VERSION, TERMSCP_AUTHORS, + ); + std::process::exit(255); + } + // TODO: ... + std::process::exit(0); +}