musica 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7def5733a1fb7f5b9d36a812d3cbf6e615d88ec49f34bdf4eb6bbcf3127f613
4
- data.tar.gz: 1d07b3cf2461f9e5e91fe29b72272c49b53c06ce2d3e6ec0c56ce2663566d713
3
+ metadata.gz: 68997c53cdcb8c578599e7ede93568d15db73adf953c7c6d674e382aed778ee5
4
+ data.tar.gz: f5591c92f6bae98c446a2a8bce0be35f6c18749475fe9f553a8fdd79d36c779a
5
5
  SHA512:
6
- metadata.gz: 1341f4bf9097a0aba074697a3f9335fe36e73b113ef2fb841920f2b3bcca0ed711084437451ea68ac0b9f20b78c2d764b4d3916bb0cef149bbcdf359d10c4b42
7
- data.tar.gz: 2688cf16ee45c9f0f676eea0f938b0c232968e1178b45a2459e88633f564fd239036d35ea7d7befe60451f56a224921007f72b82507b91647fcd72f80feacb44
6
+ metadata.gz: 7945760f5d031faf50a9dd0b0161a2b26e5c127214a78c0b15cefeb58d165980640bd7c52d91a02f98d7f71906748d65143e39fb094a2678d4c5c582bbd0b736
7
+ data.tar.gz: 4ba20cab7bb5ac547b172936eabf69b6d154b6a450faaa3da4f0f57fe7f6eed95f9e11d9bf849dea6eb95b8bd62913dd5b25e8533f0bb44355b0d7360b6c149c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.3.0] - 2026-10-19
2
+
3
+ - Turn plain requests into commands by default, without `-n`
4
+ - Send AppleScript commands as is with `-s`/`--script`, which was the default before
5
+ - Add `-h`/`--help` and `-v`/`--version`
6
+
1
7
  ## [0.2.0] - 2026-10-19
2
8
 
3
9
  - Add natural language commands with `-n`, using Apple's on-device model through `fm`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- musica (0.2.0)
4
+ musica (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -15,24 +15,25 @@ If bundler is not being used to manage dependencies, install the gem by executin
15
15
 
16
16
  ## Usage
17
17
 
18
- Musica passes its arguments straight to your music player as an AppleScript
19
- command, so `musica <command>` runs:
18
+ Tell Musica what you want in plain words:
20
19
 
21
- ```applescript
22
- tell application "<player>" to <command>
23
- ```
20
+ $ musica skip this song
21
+ $ musica turn it down a bit
22
+ $ musica play Digital Love by Daft Punk
23
+ $ musica play something by Queen
24
+ $ musica play the album Adore
24
25
 
25
- Any command in the player's AppleScript dictionary works (open it in Script
26
- Editor with File > Open Dictionary). For example:
26
+ Musica uses Apple's on-device model, through the `fm` command, to turn the
27
+ request into a command for your music player. This needs macOS 26 with Apple
28
+ Intelligence.
27
29
 
28
- $ musica play
29
- $ musica pause
30
- $ musica playpause
31
- $ musica next track
32
- $ musica previous track
33
- $ musica set sound volume to 50
30
+ It understands play, pause, next and previous track, volume changes, and
31
+ playing a track or album from your library by name, artist or album. To play
32
+ an album in order, Musica fills a playlist named "Musica" with its tracks and
33
+ plays that playlist, replacing what was in it before. Playing from your library
34
+ only works with Music.
34
35
 
35
- After each command, Musica prints the current status: the artist and track
36
+ After each request, Musica prints the current status: the artist and track
36
37
  while playing, otherwise the player state:
37
38
 
38
39
  $ musica play
@@ -40,31 +41,23 @@ while playing, otherwise the player state:
40
41
  $ musica pause
41
42
  🎧 paused
42
43
 
43
- Run `musica` without arguments to print the status alone.
44
-
45
- Commands can differ between players. For example, Music uses
46
- `set shuffle enabled to true` and Spotify uses `set shuffling to true`. Wrap
47
- commands that contain quotes in single quotes so the shell keeps them:
44
+ Run `musica` without arguments to print the status alone, `musica --help` for
45
+ a summary of the options, and `musica --version` for the version.
48
46
 
49
- $ musica 'play playlist "Favorite Songs"'
47
+ ### AppleScript
50
48
 
51
- ### Natural language
49
+ With `-s` (or `--script`), Musica sends its arguments to the player as an
50
+ AppleScript command, without `fm`. Any command in the player's AppleScript
51
+ dictionary works (open it in Script Editor with File > Open Dictionary):
52
52
 
53
- With `-n`, Musica uses Apple's on-device model, through the `fm` command, to
54
- turn a plain request into a command. This needs macOS 26 with Apple
55
- Intelligence.
53
+ $ musica -s playpause
54
+ $ musica -s set sound volume to 50
56
55
 
57
- $ musica -n skip this song
58
- $ musica -n turn it down a bit
59
- $ musica -n play Digital Love by Daft Punk
60
- $ musica -n play something by Queen
61
- $ musica -n play the album Adore
56
+ Commands can differ between players. For example, Music uses
57
+ `set shuffle enabled to true` and Spotify uses `set shuffling to true`. Wrap
58
+ commands that contain quotes in single quotes so the shell keeps them:
62
59
 
63
- It understands play, pause, next and previous track, volume changes, and
64
- playing a track or album from your library by name, artist or album. To play
65
- an album in order, Musica fills a playlist named "Musica" with its tracks and
66
- plays that playlist, replacing what was in it before. Playing from your library
67
- only works with Music.
60
+ $ musica -s 'play playlist "Favorite Songs"'
68
61
 
69
62
  ## Configuration
70
63
 
data/lib/musica/cli.rb CHANGED
@@ -2,25 +2,61 @@
2
2
 
3
3
  module Musica
4
4
  class Cli
5
- def initialize(argv, player: Player.new(application: Config.player), interpreter: Interpreter.new, out: $stdout)
6
- @natural = argv.first == "-n"
7
- @prompt = argv.drop(@natural ? 1 : 0).join(" ")
5
+ HELP = <<~TEXT
6
+ Usage: musica [request]
7
+ musica -s <applescript>
8
+
9
+ Without arguments, print what's playing. With a request, turn it into a
10
+ command using fm, send it to the music player, then print what's playing.
11
+
12
+ Options:
13
+ -s, --script Send an AppleScript command to the player as is
14
+ -h, --help Show this help
15
+ -v, --version Show the version
16
+
17
+ Examples:
18
+ musica skip this song
19
+ musica play the album Adore
20
+ musica -s set sound volume to 50
21
+
22
+ The player is set in musica/config.yml, under $XDG_CONFIG_HOME or ~/.config.
23
+ TEXT
24
+
25
+ def initialize(argv, player: nil, interpreter: nil, out: $stdout)
26
+ @argv = argv
8
27
  @player = player
9
28
  @interpreter = interpreter
10
29
  @out = out
11
30
  end
12
31
 
13
32
  def run
14
- player.tell command unless prompt.empty?
15
- out << "\u{1F3A7} #{player.status}\n"
33
+ case argv.first
34
+ when "-h", "--help"
35
+ out << HELP
36
+ when "-v", "--version"
37
+ out << "musica #{VERSION}\n"
38
+ when "-s", "--script"
39
+ play argv.drop(1).join(" ")
40
+ else
41
+ play(argv.empty? ? "" : interpreter.call(argv.join(" ")))
42
+ end
16
43
  end
17
44
 
18
45
  private
19
46
 
20
- attr_reader :interpreter, :natural, :out, :player, :prompt
47
+ attr_reader :argv, :out
48
+
49
+ def play(command)
50
+ player.tell command unless command.empty?
51
+ out << "\u{1F3A7} #{player.status}\n"
52
+ end
53
+
54
+ def player
55
+ @player ||= Player.new(application: Config.player)
56
+ end
21
57
 
22
- def command
23
- natural ? interpreter.call(prompt) : prompt
58
+ def interpreter
59
+ @interpreter ||= Interpreter.new
24
60
  end
25
61
  end
26
62
  end
@@ -28,7 +28,7 @@ module Musica
28
28
 
29
29
  output
30
30
  rescue Errno::ENOENT
31
- raise Error, "Natural language commands need fm (macOS 26 with Apple Intelligence)"
31
+ raise Error, "Requests need fm (macOS 26 with Apple Intelligence); use -s to send AppleScript instead"
32
32
  end
33
33
 
34
34
  COMMANDS = {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Musica
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: musica
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ariel Rzezak
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 4.0.17
58
+ rubygems_version: 4.0.23
59
59
  specification_version: 4
60
60
  summary: Control macOS music players from the command-line
61
61
  test_files: []