🎧 The official command-line interface for Rocksky — a modern, decentralized music tracking and discovery platform built on the AT Protocol.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

colorize nowplaying output

+20 -11
+20 -11
src/cmd/nowplaying.ts
··· 3 3 import fs from "fs/promises"; 4 4 import os from "os"; 5 5 import path from "path"; 6 + import chalk from "chalk"; 6 7 7 8 export async function nowplaying(did?: string) { 8 9 const tokenPath = path.join(os.homedir(), ".rocksky", "token.json"); ··· 10 11 await fs.access(tokenPath); 11 12 } catch (err) { 12 13 console.error( 13 - `You are not logged in. Please run ${chalk.greenBright( 14 - "`rocksky login <username>.bsky.social`" 15 - )} first.` 14 + `You are not logged in. Please run ${ 15 + chalk.greenBright( 16 + "`rocksky login <username>.bsky.social`", 17 + ) 18 + } first.`, 16 19 ); 17 20 return; 18 21 } ··· 21 24 const { token } = JSON.parse(tokenData); 22 25 if (!token) { 23 26 console.error( 24 - `You are not logged in. Please run ${chalk.greenBright( 25 - "`rocksky login <username>.bsky.social`" 26 - )} first.` 27 + `You are not logged in. Please run ${ 28 + chalk.greenBright( 29 + "`rocksky login <username>.bsky.social`", 30 + ) 31 + } first.`, 27 32 ); 28 33 return; 29 34 } ··· 37 42 console.log("No track is currently playing."); 38 43 return; 39 44 } 40 - console.log(`${nowPlaying.title} - ${nowPlaying.artist}`); 45 + console.log(chalk.magenta(`${nowPlaying.title} - ${nowPlaying.artist}`)); 41 46 console.log(`${nowPlaying.album}`); 42 47 return; 43 48 } 44 49 45 50 console.log( 46 - `${nowPlaying.item.name} - ${nowPlaying.item.artists 47 - .map((a) => a.name) 48 - .join(", ")}` 51 + chalk.magenta( 52 + `${nowPlaying.item.name} - ${ 53 + nowPlaying.item.artists 54 + .map((a) => a.name) 55 + .join(", ") 56 + }`, 57 + ), 49 58 ); 50 59 console.log(`${nowPlaying.item.album.name}`); 51 60 } catch (err) { 52 61 console.log(err); 53 62 console.error( 54 - `Failed to fetch now playing data. Please check your token and try again.` 63 + `Failed to fetch now playing data. Please check your token and try again.`, 55 64 ); 56 65 } 57 66 }