- Notifications
You must be signed in to change notification settings - Fork14
kiliankoe/CLISpinner
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
60+ spinners for use in the terminal
Shamelessly ripped off fromsindresorhus/cli-spinners.
.package(url:"https://github.com/kiliankoe/CLISpinner", from:"see latest release")
Just want to display a simple spinner for two seconds?
lets=Spinner(pattern:.dots)s.start()sleep(2)s.stop()
Want some changing text and patterns?
lets=Spinner(pattern:.dots, text:"Foobar...", color:.lightCyan)s.start()sleep(2)s.succeed(text:"Barfoo")// will change the displayed text to '✔ Barfoo'
Made your own custom pattern?
letpattern=tryPattern.load(from:"/path/to/your/pattern.json")lets=spinner(pattern: pattern)s.start()sleep(2)s.stop()
Want all the patterns fromsindresorhus/cli-spinners?
letpatterns=tryPatterns(from:"/path/to/spinners.json")lets=spinner(pattern:patterns["christmas"]!)s.start()sleep(2)s.stop()
That's basically it 👌
ThePattern type can read in patterns from a JSON file using the following format:
{"frames": ["1","2","3","4","5" ],"speed":0.08}To keep multiple patterns in a single file:
{"pattern-name1": {"frames": ["<(**<)","<(**)>","(>**)>" ],"speed":0.01 },"pattern-name2": {"frames": ["1","2","3","2" ],"speed":0.12 }}To looknice the spinner hides the user's cursor as long as it's running and displays it again when stopped. The issue with this is that the cursor will still be hidden if the user interrupts the process (by sending a SIGINT throughctrl+c for example). The best way to handle this is by setting up a signal handler in your code and callingspinner.unhideCursor() on exiting. This library purposefully does not do that for you so as not to interfere with any possible signal handlers you might already have set up.
SeeIBM-Swift/BlueSignals for a clean and safe way of handling signals. The appropriate signal handler for your project could look something like this.
import Signalsletspinner=Spinner(pattern:.dots)// ...Signals.trap(signal:.int){ _in spinner.unhideCursor()exit(0)}
- kiliankoe/apodidae - CLI to search for Swift packages
- Swift-Watch/Watcher - file watcher and test runner for Swift projects
- Your project? 😊
About
Swifty Terminal Spinner
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
