Giter Club home page Giter Club logo

spinner's Introduction

Software developer at Arup, climber and open-source advocate from the Midlands UK.

spinner's People

Contributors

dominicegginton avatar yury avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

spinner's Issues

Improved Clearing Sinner Capability

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.

Contributing README File

This would be really nice to have a README file for contributing. Should fully explain the process of contributing to the project πŸ˜€

Duration is not changing

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!

Add Colour To The Spinner Pattern

We could add color to the spinner pattern. This could be done of the init of the spinner. Maybe could be updated with public func ?

Completion functions render incorrectly when paired with custom format

Steps to reproduce

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")

Expected behavior

This should render final completion frame next to the text

Actual behavior

This renders the final completion frame with space between the text and the spinner

Environment

  • Swift version: 5.1
  • OS version: 10.15 Beta (19A558d)

Support for Formatting 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]”.

Completion Functions Display with Wrong 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.

Steps to reproduce

let spinner = Spinner(.dots, "example", color: .red)
spinner.start()
spinner.succeed()

Expected behavior

.succeed() should display a green tick

Actual behavior

.succeed() displays a red tick. this is the custom color that the spinner was set up with

Environment

  • Swift version: 5.0.1
  • OS version: macOS 10.14.6 Beta (18G29g)

Spinner renders default color as white

Steps to reproduce

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()

Expected behavior

The spinner pattern should render as the default color of the terminal not white

Actual behavior

The spinner pattern renders as white

Environment

  • Swift version: 5.1
  • OS version: 10.15 Beta (19A558d)

Color

Adding color to the spinner objects would be nice. This would be helpful when calling for errors, warnings and fails.

Implementation

Could be implemented using the Rainbow Package

Clear function does not return to start of line

Steps to reproduce

import Spinner
import Foundation

let spinner = Spinner(.dots, "Spinner Text")
spinner.start()
sleep(3)
spinner.clear()
print("Not at start of line")

Expected behavior

Text should be printed at start of line

Actual behavior

Text is printed behind padding

Environment

  • Swift version: Apple Swift version 4.2.1
  • OS version: macOS 10.14.2

Support Time Recording

It would be really nice to support recoding the time between the start and finish of the spinner, and enable the user to display the time the spinner was active. Useful to benchmark code too πŸ˜„

Stop function does display space between final frame and text

Steps to reproduce

let spinner = Spinner(.dots, "Loading Unicorns")
spinner.start()
sleep(2)
spinner.stop(finalFrame: "πŸ¦„")

Expected behavior

The spinner should display a space between the final frame and the text

Actual behavior

The spinner does not display a space between the final frame and the text

Environment

  • Swift version: 5.0.1
  • OS version: 0.14.6 Beta (18G29g)

New Animated Demo

Better demo in the readme files will attack more users of the library. Could also include gifs in the documentation

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.