Software developer at Arup, climber and open-source advocate from the Midlands UK.
dominicegginton / spinner Goto Github PK
View Code? Open in Web Editor NEWPowerful Swift CLI Spinners
License: MIT License
Powerful Swift CLI Spinners
License: MIT License
Software developer at Arup, climber and open-source advocate from the Midlands UK.
Currently .stopAndClear()
clears both the spinner frame and text and returns to a new line. It would be nice to have the option for a better .clear()
functionality where a new line isnβt created and the cursor is reset to the start of the line.
It would be nice to display the progress of mutli step jobs with an output somthing similar to: [3/4]
Spinner length can cause issues when changing from larger to smaller.
let spinner = Spinner(.dots, message, format: "{S} {T} β±οΈ {D}")
spinner.start()
//example of command more then 1s:
shell.run("bundle exec pod install")
spinner.stop()
//Output:
β π« Pods install β±οΈ 0s
I checked your code and it looks correct, you calculate the value between the start and the current time each time. However, the value does not change
func render() {
var spinner = self.format.replacingOccurrences(of: "{S}", with: self.frame()).replacingOccurrences(of: "{T}", with: self.message)
if let timestamp = self.timestamp {
let duration = Now() - timestamp
spinner = spinner.replacingOccurrences(of: "{D}", with: duration.timeString)
}
stream.write(string: "\r", terminator: "")
stream.write(string: spinner, terminator: "")
}
Thank you for good project!
If a spinner has a custom completion type with the animated pattern rendering after the text and a completion function is used to stop the spinner, a render error can occur if the passed text is shorter than the original. I am assuming this will occur when updating the text too.
let mySpinner = Spinner(.dots, "My Spinner", format: "{T} {S}")
mySpinner.start()
sleep(2)
mySpinner.failure("Fail")
This should render final completion frame next to the text
This renders the final completion frame with space between the text and the spinner
Current spinner object prints the pattern frames before the text object. It would be nice to implement support for formatting this output. For example:
Spinner Text .
Spinner Text ..
Spinner Text ...
Spinner Text ....
Spinner Text β
This could be implemented with a string that is passed to the Spinner object. For example, β[p] [t]β
.
Demo gifs should have a transparent background enabling both light and dark modes for GitHub to display the demos without a jarring background color
When calling a completion hander the if the spinner has a custom color set it will override the completion spinners color and display the currently set color.
let spinner = Spinner(.dots, "example", color: .red)
spinner.start()
spinner.succeed()
.succeed()
should display a green tick
.succeed()
displays a red tick. this is the custom color that the spinner was set up with
Set your terminal to a different color by default, then create a default Spinner object.
import Spinner
let mySpinner = Spinner(.dots, "My Spinner")
mySpinner.start()
sleep(2)
mySpinner.stop()
The spinner pattern should render as the default color of the terminal not white
The spinner pattern renders as white
Adding color to the spinner objects would be nice. This would be helpful when calling for errors, warnings and fails.
Could be implemented using the Rainbow Package
Add this repository to dependabot, enabling automated dependency updates.
Waiting on dependabot/dependabot-core#1379 to be merged.
import Spinner
import Foundation
let spinner = Spinner(.dots, "Spinner Text")
spinner.start()
sleep(3)
spinner.clear()
print("Not at start of line")
Text should be printed at start of line
Text is printed behind padding
let spinner = Spinner(.dots, "Loading Unicorns")
spinner.start()
sleep(2)
spinner.stop(finalFrame: "π¦")
The spinner should display a space between the final frame and the text
The spinner does not display a space between the final frame and the text
Update swift-tools-version
here to latest version:
https://github.com/dominicegginton/Spinner/blob/8d1e008264c5c0c93a8c779028b7c8c20173d7ca/Package.swift#L1
Spinner currently hides the terminal cursor when started and unhides the cursor when stopped. If the process is interrupted (For Example Ctrl + C
)
I tried changing: https://github.com/mattyoung/spinner
but I don't know why I get:
/Users/matty/Devel/ArgumentParser/Projects/WebGrep/Sources/WebGrep.swift:93:19 Value of type 'Spinner' has no member 'updateText'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.