npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@s54a/cliclock

v4.0.0

Published

Clock, Timer, StopWatch in Command Line

Downloads

7

Readme

Table of Contents generated with DocToc

@s54a/CLI Clock || CLI Clock && Timer && Stopwatch

CliClock is a command-line tool that allows users to perform various time-related functions such as displaying the current time, starting a stopwatch, setting a timer, and more, all from the comfort of their terminal.

Installation

This package provides an Executable Command

So You will have to install this package globally to be able to use the init command.

npm install -g @s54a/cliclock

OR

npx @s54a/cliclock

Features

  • Display Current Time: Simply type t to display the current time.
  • Stopwatch Functionality: Start a stopwatch by typing t -s.
  • Set a Timer: Set a timer by typing t [time]. Supported time units include hours (h), minutes (m), and seconds (s).
  • Funny Sound Option: Add a fun element to your timer with the -f flag, e.g., t 10m -f.
  • Customize VLC Path: Set the path to the VLC executable for audio playback.
  • Customize Audio Path: Set the path to the audio file for the alarm, including the option to use the default audio file.

Usage

  • To display the current time:

    t
  • To start a stopwatch:

    t -s
  • To set a timer:

    t [time]

    Example: t 10m (for 10 minutes)

    I have wasted a lot of timer on Regex so all these are correct inputs

    "1h 42 m 30 s"
    "1h42m30s"
    "1 h 42 m 30 s"
    "1 m 30 s"
    "1m 30s"
    "1m 30 s"
    "30 s"
    "1h30 s"
    " 1 h 30 s "
  • To set a timer with a funny sound:

    t [time] -f
  • To set the path to the VLC executable:

    t --vlc-path [path]
  • If you don't have VLC installed or don't want to play sound when the timer ends you can just set VLC.exe Path as no

    t --vlc-path no
  • To set new Audio for when the timer Ends:

    t --audio-path [path]
  • To set back to default:

    t --audio-path "default-audio"

For a detailed help menu, type:

t -h
  • To exit any time press Esc

Folder Structure

📁 cliClock
├── 📁 src
│ ├── 📄 cliInterface.js
│ ├── 📄 config.js
│ ├── 📄 exitCliClock.js
│ ├── 📄 fixWindowsPath.js
│ ├── 📄 getVLCPath.js
│ ├── 📄 handleSnoozeInput.js
│ ├── 📄 index.js
│ ├── 📄 notifyTimer.js
│ ├── 📄 parseTimeInput.js
│ ├── 📄 runCommand.js
│ ├── 📄 saveConfig.js
│ ├── 📄 setDefaultAudioPath.js
│ └── 📄 soundFunctions.js
├── 📄 .gitignore
├── 🎵 audio.mp3
├── 🎵 sound.mp3
├── 📜 LICENSE
├── 📝 Readme.md
├── 📋 package.json
├── 📋 package-lock.json
└── 🖼️ timer-svgrepo-com.png

Github

https://github.com/s54a/s54a-cliclock

NPM

https://www.npmjs.com/package/@s54a/cliclock

License

This project is licensed under the MIT License

Why I Made this:

It would an under statement to say that I have been a Professional Times Waster.

I way I figured out to Waste Less Time was setting timer then waste my time only till the timer ended.

But it was a hassle to set timers usi GUI so for a really long timer I wanted to build a CLI Timer.

So some time ago learned to make CLI Programs using Node JS. So I made this.

And I have spent a bit much to make it cross platform but I didn't had the resources to Test it so feel free to make any changes

How it works (A bit of Code Explanation)

I will explain the Timer Part only rest is very simple

First it runs a function called getVLCPath. It guess a correct path for the VLC.exe but if it all possible guessed paths are wrong then it will prompt you to enter the VLC.exe path.

If you don't want to give the path for VLC.exe you can answer no and it will start the timer but won't play the audio file.

But you can change this behavior any time by using the --vlc-path flag and set path for VLC.exe and it will play the audio.

But I have set it so that it will play a beep sound or whatever your system has using the Node-Notifier when the timer ends.

Then it sets the path for sound.mp3 in config.js so that VLC can play the sound.

Then it passes the user input through parseInputTimer function which extracts the units for timer and starts a timer using Set Interval.

When the timer ends it uses node-notifier to send notifications. And in the push notification there is an option to Snooze Timer for 3 Minutes & Another Option to End Timer

While in terminal it prompts you to snooze timer which uses the Readline Module. Input Time & Press Enter and it will restart Timer.

So I the timer never stops if you want to stop it you will have to press ESC or CTRL + C on your Keyboard

There is a bug or a little inconvenience in the Package when you snooze the timer and then if you try to exit the timer while it is running it takes almost 3 seconds to exit.

I don't know why it happens.

And I have tried to fix but it I can't there were a few fixes such just remove the function to exit and the user can exit by pressing CTRL + C.

A few question you might ask

Why there is a file called fixWindowsPath.js ?

Well File paths in windows use "" which in JS is used as a Escape Character and then it creates issues.

What I have learned after making a few NPM Packages

What you are trying to build will be build very easily but the validation, errors, more feature, things which you didn't planned for, and etc

e.g. When I started to build this package the Timer, StopWatch, Clock Functionality was done in about Two Hours but I wanted to send notification and play sound then I wanted the user to have the ability to enter timer in any format, then being able to change the audio it took more then 20 Days.

If you are a web developer you will think there must a native in node js to play sound and stop playing sound.

But there isn't.

So I think & according to this StackOverFlow answer there are Four Packages

  • Node Speaker (I cant figure this one)
  • Audic (The Size Bloats to 180 MBs)
  • SoundPlay (It can play sound but can't stop it)
    • I tried to change the source code and the functionality to stop the playing sound but it didn't happen.
    • So after banging my head on this issue for a few days Chat GPT gave me a solution to play sound using VLC Media Player and it was cross platform as well.
    • I will create this as a package and upload soon.
  • PlaySound (Didn't work)
Credit For Timer Ending Sound

Sound Effect by UNIVERSFIELD from Pixabay