Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .replit
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
run = "swift run repyfi --help"

compile = "swift build || swift package clean && clear"

[nix]
channel = "stable-22_11"
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"configurations": [
{
"type": "lldb",
"request": "launch",
"sourceLanguages": [
"swift"
],
"name": "Debug repyfi",
"program": "${workspaceFolder:repyfi-cli}/.build/debug/repyfi",
"args": [],
"cwd": "${workspaceFolder:repyfi-cli}",
"preLaunchTask": "swift: Build Debug repyfi"
},
{
"type": "lldb",
"request": "launch",
"sourceLanguages": [
"swift"
],
"name": "Release repyfi",
"program": "${workspaceFolder:repyfi-cli}/.build/release/repyfi",
"args": [],
"cwd": "${workspaceFolder:repyfi-cli}",
"preLaunchTask": "swift: Build Release repyfi"
}
]
}
20 changes: 10 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// swift-tools-version: 5.6
// swift-tools-version: 5.4
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "RepeatCLI",
name: "RepyfiCLI",
products: [
.executable(name: "repyfi", targets: ["RepyfiCLI"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.2.0")
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.0.0"),
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.executableTarget(
name: "repeat-cli",
dependencies: [
.product(name: "ArgumentParser", package: "swift-argument-parser")
])
name: "RepyfiCLI",
dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser")]),
]
)
93 changes: 30 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,77 +1,44 @@
<div align="center">
<h1>Repify CLI</h1>
<p>
A lightweight and user-friendly command-line application designed for text repeating.
</p>
<p>
<img src="https://github.com/jaroshevskii/repify-cli/assets/72662383/1429dbe5-1b6a-453e-8ac9-5332b46d462d">
</p>
<p>
<a href="https://swiftpackageindex.com/jaroshevskii/repeat-cli">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjaroshevskii%2Frepify-cli%2Fbadge%3Ftype%3Dswift-versions" alt="Swift Compatibility">
</a>
<a href="https://swiftpackageindex.com/jaroshevskii/repeat-cli">
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjaroshevskii%2Frepify-cli%2Fbadge%3Ftype%3Dplatforms" alt="Platform Compatibility">
</a>
<img src="https://img.shields.io/badge/Platform%20Compatibility-Windows-blue" alt="Platform Compatibility Windows">
</p>
</div>

<!--
[![Swift Compatibility](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjaroshevskii%2Frepeat-cli%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/jaroshevskii/repeat-cli)
[![Platform Compatibility](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fjaroshevskii%2Frepeat-cli%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/jaroshevskii/repeat-cli)
![Platform Compatibility Windows](https://img.shields.io/badge/Platform%20Compatibility-Windows-blue)
-->

<!--
RepeatCLI is a simple [command-line](https://en.wikipedia.org/wiki/Command-line_interface) application for text repeating, inspired on the [Example Repeat](https://github.com/apple/swift-argument-parser/blob/doc-generation/Examples/repeat/Repeat.swift) from [Swift Argument Parser](https://github.com/apple/swift-argument-parser) library.
-->

<!--
```zsh
% repeat-cli 'This text will be repeated three times with a counter 🦄' \
--count 3 \
--include-counter
1: This text will be repeated three times with a counter 🦄
2: This text will be repeated three times with a counter 🦄
3: This text will be repeated three times with a counter 🦄
```
-->
<h1 align="center">Repify CLI</h1>
<p align="center">A lightweight and user-friendly tool for effortlessly repeating and customizing text.</p>

<!-- ![Baner](https://github.com/jaroshevskii/repify-cli/assets/72662383/03a9702c-6937-4f2b-bc7f-562533cdf2b7) -->

![Baner](https://github.com/jaroshevskii/repify-cli/assets/72662383/fd8b929c-a9a1-489d-b48a-1765e4a800ee)

## Installation

RepeatCLI is not yet available in any package manager and there are no compiled versions 😮‍💨. So you have to compile manually.
Repyfi CLI is not yet available in any package manager and there are no compiled versions 😮‍💨. So you have to compile manually.

## Usage

RepeatCLI is a CLI application, this means that the **application must be executed from the [Terminal](https://en.wikipedia.org/wiki/Terminal_emulator)**.
Repyfi CLI is a CLI application, this means that the **application must be executed from the [Terminal](https://en.wikipedia.org/wiki/Terminal_emulator)**.

### Basic repetition

Use `repeat-cli <text>` to repeat the text. Where `<text>` is your text.
Use `repyfi <text>` to repeat the text. Where `<text>` is your text.

```zsh
repeat-cli Hello
repyfi Hello
```

**Result:**

```zsh
% repeat-cli Hello
% repyfi Hello
Hello
Hello
```

To repeat several words or even whole sentences, the text must be wrapped with an `'` or `"` symbol on both sides.

```zsh
repeat-cli 'Be faster 🐢'
repyfi 'Be faster 🐢'
```

**Result:**

```zsh
% repeat-cli 'Be faster 🐢'
% repyfi 'Be faster 🐢'
Be faster 🐢
Be faster 🐢
```
Expand All @@ -89,19 +56,19 @@ By default, the text will be repeated only twice.
To set a custom number of repetitions, use `--count <count>` option. Where `<count>` is a number.

```zsh
repeat-cli 'I promise to always use UTF-8 🐶' --count 5
repyfi 'I promise to always use UTF-8 🐶' --count 5
```

> **Note:** You can also use shorter entry.
>
> ```zsh
> repeat-cli 'I promise to always use UTF-8 🐶' -c 5
> repyfi 'I promise to always use UTF-8 🐶' -c 5
> ```

**Result:**

```zsh
% repeat-cli 'I promise to always use UTF-8 🐶' --count 5
% repyfi 'I promise to always use UTF-8 🐶' --count 5
I promise to always use UTF-8 🐶
I promise to always use UTF-8 🐶
I promise to always use UTF-8 🐶
Expand All @@ -120,18 +87,18 @@ I promise to always use UTF-8 🐶
To include a repetition counter, use `--include-counter` option.

```zsh
repeat-cli 'Yare yare daze...' --count 3 --include-counter
repyfi 'Yare yare daze...' --count 3 --include-counter
```
> **Note:** You can also use shorter entry.
>
> ```zsh
> repeat-cli 'Yare yare daze...' -c 3 -i
> repyfi 'Yare yare daze...' -c 3 -i
> ```

**Result:**

```zsh
% repeat-cli 'Yare yare daze...' --count 3 --include-counter
% repyfi 'Yare yare daze...' --count 3 --include-counter
1: Yare yare daze...
2: Yare yare daze...
3: Yare yare daze...
Expand All @@ -144,24 +111,24 @@ Multiline may be useful if you need to repeat a text that consists of several li
To use multilining, you must use `\` as if it were a newline character.

```zsh
repeat-cli 'Dum-dum-dum-dum, ditty dum-dum-dum \
Dum, dum, dum'
repyfi 'Dum-dum-dum-dum, ditty dum-dum-dum \
Dum, dum, dum'
```

**Result:**

```zsh
% repeat cli 'Dum-dum-dum-dum, ditty dum-dum-dum \
Dum, dum, dum'
% repyfi 'Dum-dum-dum-dum, ditty dum-dum-dum \
Dum, dum, dum'
Dum-dum-dum-dum, ditty dum-dum-dum
Dum, dum, dum
Dum-dum-dum-dum, ditty dum-dum-dum
Dum, dum, dum
```

### Arguments order does not matter
### Arguments order

RepeatCLI uses the following order of arguments:
Rpyfi CLI uses the following order of arguments:

```
<text> [--count <count>] [--include-counter]
Expand All @@ -171,14 +138,14 @@ But that doesn't mean you have to follow it. **Any combination of arguments will

The following commands will work the same way:

- `repeat-cli --count 1 --include-counter 'Hello everyone!'`
- `repeat-cli -с 1 'Hello everyone!' --include-counter `
- `repeat-cli -i --count 1 'Hello everyone!'`
- `repyfi --count 1 --include-counter 'Hello everyone!'`
- `repyfi -с 1 'Hello everyone!' --include-counter `
- `repyfi -i --count 1 'Hello everyone!'`

## Contributing

Interested in contributing to RepeatCLI? We'd love your help. RepeatCLI is an open source project, built one contribution at a time by users like you.
Interested in contributing to Repyfi CLI? We'd love your help. Repyfi CLI is an open source project, built one contribution at a time by users like you.

## License

Licensed under the [MIT License](LICENSE).
Licensed under the [MIT License](LICENSE.md).
74 changes: 74 additions & 0 deletions Sources/RepyfiCLI/Repyfi.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// Repyfi.swift
// RepyfiCLI
//

import ArgumentParser
import Foundation

/// A lightweight and user-friendly tool for effortlessly repeating and customizing text.
@main
struct Repyfi: ParsableCommand {
static let configuration = CommandConfiguration(
abstract: "A lightweight and user-friendly tool for effortlessly repeating and customizing text.",
discussion: """
With Repyfi CLI, you can unleash your creativity by easily creating endless variations of text with just a few simple commands.

LINKS:
Website: https://repyfi.github.io
Discussions: https://github.com/repyfi/repyfi-cli/discussions
Issues: https://github.com/repyfi/repyfi-cli/issues
Repository: https://github.com/repyfi/repyfi-cli
""",
version: """
Repyfi CLI version \(version)
Release: https://github.com/repyfi/repyfi-cli/releases/tag/v\(version)
"""
)

/// The text to be repeated.
@Argument(help: "The text to be repeated.")
var text: String

/// The number of text repetitions.
@Option(name: .shortAndLong, help: "The number of text repetitions.")
var count = 2

/// Include repetition numbering.
@Flag(name: .shortAndLong, help: "Include repetition numbering.")
var includeNumbering: Bool = false

/// The repetition format.
@Option(name: .shortAndLong, help: "The repetition format. Use \\(text) and \\(number) as placeholders.")
var format: String?

/// Separator between repetitions.
@Option(name: .shortAndLong, help: "The separator between repetitions.")
var separator = "\n"

/// The delay (in seconds) between repetitions.
@Option(name: .shortAndLong, help: "The delay (in seconds) between repetitions.")
var delay: Double?

func run() {
for i in 1...count {
var formattedText: String
if let format = format {
formattedText = format
.replacingOccurrences(of: "\\(text)", with: text)
.replacingOccurrences(of: "\\(number)", with: "\(i)")
} else {
formattedText = includeNumbering ? "\(i): \(text)" : text
}

if i < count {
print(formattedText, terminator: separator)
if let delay = delay {
Thread.sleep(forTimeInterval: delay)
}
} else {
print(formattedText)
}
}
}
}
8 changes: 8 additions & 0 deletions Sources/RepyfiCLI/Version.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Version.swift
// RepyfiCLI
//

extension Repyfi {
static let version = "1.0.0-rebuild"
}
Loading