checkoff 0.280.0 → 0.281.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: '047309b0535e5f8e80692579a52abe2f7a5503273f0f601dd52a3b8ad96e1fa7'
4
- data.tar.gz: 3b15481f44c0c8d8f62827485230ce740208f724e1e93fded7a11afc4be2ff5a
3
+ metadata.gz: 2e40ee8d21c716a72afc0d414168b438fc360e5100d0a5f1d3de44f2af6c67b8
4
+ data.tar.gz: de2d39a04cde9dee6e193239a9cef2ad3d9b60376b5278f27c3236c9e22c891b
5
5
  SHA512:
6
- metadata.gz: '0385163ea888d155984ae5c4b597ae38e29f320927752d7f07f544c50f53d3e449b8d8f62473f2a29187b92049570388259796ea04a94ab3d2c29752ad5b4f42'
7
- data.tar.gz: 96732bac021559a0d497b53df45c313d2c09b846011571b35e5943d19931862b8eaad13f42e9b935992eae6cba69a1c010c0ff4f553bdba2da56cce9d1c9cb23
6
+ metadata.gz: 758556c581d5a7148f2e3b9abb703a3860a3511f638dc11c83df238c79fc8d02cb918b8d1b39585b33beade1c06fd3dc683a3d4da1dd8237fbfeb90e1cbcaa1d
7
+ data.tar.gz: '082e085a622c932d9c60b5e5434c4d9d7a2ad96f20ff4a7f6cb675588ef0cce12546f8709720871cba404fa7eedcbbb778a262e01bbff0c83b8bcf69148e1f93'
data/lib/checkoff/cli.rb CHANGED
@@ -7,6 +7,8 @@ require 'json'
7
7
  require 'ostruct'
8
8
  require 'gli'
9
9
  require 'cache_method'
10
+ require 'active_support'
11
+ require 'active_support/values/time_zone'
10
12
  require_relative 'workspaces'
11
13
  require_relative 'projects'
12
14
  require_relative 'tasks'
@@ -297,8 +299,93 @@ module Checkoff
297
299
  attr_reader :workspace_name, :task_name
298
300
  end
299
301
 
300
- # Builds the subcommands CheckoffGLIApp runs, giving the quickadd and
301
- # view subcommands the collaborators they accept out of those passed
302
+ # CLI subcommand that changes an existing task's due date or time
303
+ # and/or marks it complete
304
+ class UpdateSubcommand
305
+ TIME_ZONE = 'America/New_York'
306
+
307
+ # @param task_gid [String]
308
+ # @param due_on [String, nil] today, tomorrow or YYYY-MM-DD
309
+ # @param due_at [String, nil] a time such as 11:30am, on the
310
+ # due_on date if given, else today; or a full time such as
311
+ # 2026-12-02T11:30:00-05:00. Read in TIME_ZONE unless it
312
+ # gives an offset.
313
+ # @param complete [Boolean]
314
+ # @param config [Checkoff::Internal::EnvFallbackConfigLoader, Hash]
315
+ # @param tasks [Checkoff::Tasks]
316
+ # @param now [ActiveSupport::TimeWithZone] the current time in TIME_ZONE
317
+ def initialize(task_gid, due_on: nil, due_at: nil, complete: false,
318
+ config: Checkoff::Internal::ConfigLoader.load(:asana),
319
+ tasks: Checkoff::Tasks.new(config:),
320
+ now: zone.now)
321
+ @task_gid = task_gid
322
+ @due_on = due_on
323
+ @due_at = due_at
324
+ @complete = complete
325
+ @tasks = tasks
326
+ @now = now
327
+ end
328
+
329
+ # @return [void]
330
+ def run
331
+ changes = due_changes
332
+ changes[:completed] = true if complete
333
+ raise ArgumentError, 'Give --due_on, --due_at or --complete' if changes.empty?
334
+
335
+ tasks.update_task(task_gid, **changes)
336
+ end
337
+
338
+ private
339
+
340
+ # Asana rejects a request setting both due_on and due_at
341
+ #
342
+ # @return [Hash{Symbol => Date, ActiveSupport::TimeWithZone, Boolean}]
343
+ def due_changes
344
+ time = due_at_time
345
+ return { due_at: time } if time
346
+
347
+ date = due_on_date
348
+ return { due_on: date } if date
349
+
350
+ {}
351
+ end
352
+
353
+ # @return [ActiveSupport::TimeZone]
354
+ def zone
355
+ ActiveSupport::TimeZone[TIME_ZONE] || raise("Unknown time zone #{TIME_ZONE}")
356
+ end
357
+
358
+ # @return [Date, nil]
359
+ def due_on_date
360
+ date = due_on
361
+ return nil if date.nil?
362
+
363
+ case date
364
+ when 'today' then now.to_date
365
+ when 'tomorrow' then now.to_date + 1
366
+ else Date.iso8601(date)
367
+ end
368
+ end
369
+
370
+ # @return [ActiveSupport::TimeWithZone, nil]
371
+ def due_at_time
372
+ text = due_at
373
+ return nil if text.nil?
374
+
375
+ date = due_on_date
376
+ # Date._parse fills a bare time's missing date from this
377
+ base = date ? zone.local(date.year, date.month, date.day) : now
378
+ time = zone.parse(text, base)
379
+ raise ArgumentError, "Could not parse --due_at #{text}" unless time.is_a?(ActiveSupport::TimeWithZone)
380
+
381
+ time
382
+ end
383
+
384
+ attr_reader :task_gid, :due_on, :due_at, :complete, :tasks, :now
385
+ end
386
+
387
+ # Builds the subcommands CheckoffGLIApp runs, giving the quickadd,
388
+ # view and update subcommands the collaborators they accept out of those passed
302
389
  # here; the rest fall back to the subcommand's own defaults.
303
390
  class SubcommandFactory
304
391
  # @param mv_subcommand_class [Class<MvSubcommand>]
@@ -326,6 +413,16 @@ module Checkoff
326
413
  **@collaborators.slice(:config, :projects, :sections, :tasks, :stderr))
327
414
  end
328
415
 
416
+ # @param task_gid [String]
417
+ # @param due_on [String, nil]
418
+ # @param due_at [String, nil]
419
+ # @param complete [Boolean]
420
+ # @return [UpdateSubcommand]
421
+ def update(task_gid, due_on:, due_at:, complete:)
422
+ UpdateSubcommand.new(task_gid, due_on:, due_at:, complete:,
423
+ **@collaborators.slice(:config, :tasks, :now))
424
+ end
425
+
329
426
  # @param from_workspace_arg [Symbol, String]
330
427
  # @param from_project_arg [Symbol, String]
331
428
  # @param from_section_arg [nil, String]
@@ -391,6 +488,30 @@ module Checkoff
391
488
  end
392
489
  end
393
490
 
491
+ desc 'Change the due date or time of a task, or mark it complete'
492
+ arg 'task_gid'
493
+ # @param c [GLI::Command]
494
+ command :update do |c|
495
+ c.flag :due_on,
496
+ type: String,
497
+ desc: 'New due date: today, tomorrow or YYYY-MM-DD'
498
+ c.flag :due_at,
499
+ type: String,
500
+ desc: 'New due time in America/New_York, such as 11:30am ' \
501
+ '(on the --due_on date if given, else today), or a full ISO 8601 time'
502
+ c.switch :complete,
503
+ negatable: false,
504
+ desc: 'Mark the task complete'
505
+ # @param options [Hash]
506
+ # @param args [Array<String>]
507
+ c.action do |_global_options, options, args|
508
+ subcommand_factory.update(args.fetch(0),
509
+ due_on: options['due_on'],
510
+ due_at: options['due_at'],
511
+ complete: options['complete']).run
512
+ end
513
+ end
514
+
394
515
  desc 'Move tasks from one section to another within a project'
395
516
 
396
517
  # rubocop:disable Metrics/BlockLength
@@ -190,6 +190,20 @@ module Checkoff
190
190
  workspace: workspace_gid, name:)
191
191
  end
192
192
 
193
+ # Change fields on an existing task. Asana rejects a request
194
+ # setting both due_on and due_at.
195
+ #
196
+ # @param task_gid [String]
197
+ # @param due_on [Date, nil]
198
+ # @param due_at [Time, ActiveSupport::TimeWithZone, nil]
199
+ # @param completed [Boolean, nil]
200
+ #
201
+ # @return [Asana::Resources::Task]
202
+ def update_task(task_gid, due_on: nil, due_at: nil, completed: nil)
203
+ data = { due_on: due_on&.iso8601, due_at: due_at&.utc&.iso8601, completed: }.compact
204
+ client.tasks.update_task(task_gid:, **data)
205
+ end
206
+
193
207
  # Return user-accessible URL for a task
194
208
  #
195
209
  # @param task [Asana::Resources::Task]
@@ -4,5 +4,5 @@
4
4
  # Command-line and gem client for Asana (unofficial)
5
5
  module Checkoff
6
6
  # Version of library
7
- VERSION = '0.280.0'
7
+ VERSION = '0.281.0'
8
8
  end
data/rbi/checkoff.rbi CHANGED
@@ -82,7 +82,7 @@ module Overcommit
82
82
  end
83
83
 
84
84
  module Checkoff
85
- VERSION = '0.280.0'
85
+ VERSION = '0.281.0'
86
86
 
87
87
  class Attachments
88
88
  include Logging
@@ -305,6 +305,56 @@ module Checkoff
305
305
  attr_reader :task_name
306
306
  end
307
307
 
308
+ class UpdateSubcommand
309
+ TIME_ZONE = 'America/New_York'
310
+
311
+ sig do
312
+ params(
313
+ task_gid: T.untyped,
314
+ due_on: T.untyped,
315
+ due_at: T.untyped,
316
+ complete: T.untyped,
317
+ config: T.untyped,
318
+ tasks: T.untyped,
319
+ now: T.untyped
320
+ ).void
321
+ end
322
+ def initialize(task_gid, due_on: nil, due_at: nil, complete: false, config: Checkoff::Internal::ConfigLoader.load(:asana), tasks: Checkoff::Tasks.new(config:), now: zone.now); end
323
+
324
+ sig { returns(T.untyped) }
325
+ def run; end
326
+
327
+ sig { returns(T.untyped) }
328
+ def due_changes; end
329
+
330
+ sig { returns(T.untyped) }
331
+ def zone; end
332
+
333
+ sig { returns(T.untyped) }
334
+ def due_on_date; end
335
+
336
+ sig { returns(T.untyped) }
337
+ def due_at_time; end
338
+
339
+ sig { returns(T.untyped) }
340
+ attr_reader :task_gid
341
+
342
+ sig { returns(T.untyped) }
343
+ attr_reader :due_on
344
+
345
+ sig { returns(T.untyped) }
346
+ attr_reader :due_at
347
+
348
+ sig { returns(T.untyped) }
349
+ attr_reader :complete
350
+
351
+ sig { returns(T.untyped) }
352
+ attr_reader :tasks
353
+
354
+ sig { returns(T.untyped) }
355
+ attr_reader :now
356
+ end
357
+
308
358
  class SubcommandFactory
309
359
  sig { params(mv_subcommand_class: T.untyped, collaborators: T.untyped).void }
310
360
  def initialize(mv_subcommand_class: MvSubcommand, **collaborators); end
@@ -322,6 +372,16 @@ module Checkoff
322
372
  end
323
373
  def view(workspace_name, project_name, section_name, task_name); end
324
374
 
375
+ sig do
376
+ params(
377
+ task_gid: T.untyped,
378
+ due_on: T.untyped,
379
+ due_at: T.untyped,
380
+ complete: T.untyped
381
+ ).returns(T.untyped)
382
+ end
383
+ def update(task_gid, due_on:, due_at:, complete:); end
384
+
325
385
  sig do
326
386
  params(
327
387
  from_workspace_arg: T.untyped,
@@ -1329,6 +1389,16 @@ module Checkoff
1329
1389
  sig { params(name: T.untyped, workspace_gid: T.untyped, assignee_gid: T.untyped).returns(T.untyped) }
1330
1390
  def add_task(name, workspace_gid: @workspaces.default_workspace_gid, assignee_gid: default_assignee_gid); end
1331
1391
 
1392
+ sig do
1393
+ params(
1394
+ task_gid: T.untyped,
1395
+ due_on: T.untyped,
1396
+ due_at: T.untyped,
1397
+ completed: T.untyped
1398
+ ).returns(T.untyped)
1399
+ end
1400
+ def update_task(task_gid, due_on: nil, due_at: nil, completed: nil); end
1401
+
1332
1402
  sig { params(task: T.untyped).returns(T.untyped) }
1333
1403
  def url_of_task(task); end
1334
1404
 
@@ -2572,7 +2642,7 @@ end
2572
2642
  # typed: ignore
2573
2643
  # Command-line and gem client for Asana (unofficial)
2574
2644
  module Checkoff
2575
- VERSION = T.let('0.280.0', T.untyped)
2645
+ VERSION = T.let('0.281.0', T.untyped)
2576
2646
 
2577
2647
  # Move tasks from one place to another
2578
2648
  class MvSubcommand
@@ -3188,6 +3258,26 @@ module Checkoff
3188
3258
  sig { returns(String) }
3189
3259
  def default_assignee_gid; end
3190
3260
 
3261
+ # Change fields on an existing task. Asana rejects a request
3262
+ # setting both due_on and due_at.
3263
+ #
3264
+ # _@param_ `task_gid`
3265
+ #
3266
+ # _@param_ `due_on`
3267
+ #
3268
+ # _@param_ `due_at`
3269
+ #
3270
+ # _@param_ `completed`
3271
+ sig do
3272
+ params(
3273
+ task_gid: String,
3274
+ due_on: T.nilable(Date),
3275
+ due_at: T.nilable(T.any(Time, ActiveSupport::TimeWithZone)),
3276
+ completed: T.nilable(T::Boolean)
3277
+ ).returns(Asana::Resources::Task)
3278
+ end
3279
+ def update_task(task_gid, due_on: nil, due_at: nil, completed: nil); end
3280
+
3191
3281
  sig { returns(::Logger) }
3192
3282
  def logger; end
3193
3283
 
@@ -6702,8 +6792,8 @@ end - [Checkoff::SelectorClasses::Section::FunctionEvaluator]).freeze, T.untyped
6702
6792
  attr_reader :client
6703
6793
  end
6704
6794
 
6705
- # Builds the subcommands CheckoffGLIApp runs, giving the quickadd and
6706
- # view subcommands the collaborators they accept out of those passed
6795
+ # Builds the subcommands CheckoffGLIApp runs, giving the quickadd,
6796
+ # view and update subcommands the collaborators they accept out of those passed
6707
6797
  # here; the rest fall back to the subcommand's own defaults.
6708
6798
  class SubcommandFactory
6709
6799
  # _@param_ `mv_subcommand_class`
@@ -6757,6 +6847,95 @@ end - [Checkoff::SelectorClasses::Section::FunctionEvaluator]).freeze, T.untyped
6757
6847
  ).returns(MvSubcommand)
6758
6848
  end
6759
6849
  def mv(from_workspace_arg:, from_project_arg:, from_section_arg:, to_workspace_arg:, to_project_arg:, to_section_arg:); end
6850
+
6851
+ # _@param_ `task_gid`
6852
+ #
6853
+ # _@param_ `due_on`
6854
+ #
6855
+ # _@param_ `due_at`
6856
+ #
6857
+ # _@param_ `complete`
6858
+ sig do
6859
+ params(
6860
+ task_gid: String,
6861
+ due_on: T.nilable(String),
6862
+ due_at: T.nilable(String),
6863
+ complete: T::Boolean
6864
+ ).returns(UpdateSubcommand)
6865
+ end
6866
+ def update(task_gid, due_on:, due_at:, complete:); end
6867
+ end
6868
+
6869
+ # CLI subcommand that changes an existing task's due date or time
6870
+ # and/or marks it complete
6871
+ class UpdateSubcommand
6872
+ TIME_ZONE = T.let('America/New_York', T.untyped)
6873
+
6874
+ # _@param_ `task_gid`
6875
+ #
6876
+ # _@param_ `due_on` — today, tomorrow or YYYY-MM-DD
6877
+ #
6878
+ # _@param_ `due_at` — a time such as 11:30am, on the due_on date if given, else today; or a full time such as 2026-12-02T11:30:00-05:00. Read in TIME_ZONE unless it gives an offset.
6879
+ #
6880
+ # _@param_ `complete`
6881
+ #
6882
+ # _@param_ `config`
6883
+ #
6884
+ # _@param_ `tasks`
6885
+ #
6886
+ # _@param_ `now` — the current time in TIME_ZONE
6887
+ sig do
6888
+ params(
6889
+ task_gid: String,
6890
+ due_on: T.nilable(String),
6891
+ due_at: T.nilable(String),
6892
+ complete: T::Boolean,
6893
+ config: T.any(Checkoff::Internal::EnvFallbackConfigLoader, T::Hash[T.untyped, T.untyped]),
6894
+ tasks: Checkoff::Tasks,
6895
+ now: ActiveSupport::TimeWithZone
6896
+ ).void
6897
+ end
6898
+ def initialize(task_gid, due_on: nil, due_at: nil, complete: false, config: Checkoff::Internal::ConfigLoader.load(:asana), tasks: Checkoff::Tasks.new(config:), now: zone.now); end
6899
+
6900
+ sig { void }
6901
+ def run; end
6902
+
6903
+ # Asana rejects a request setting both due_on and due_at
6904
+ sig { returns(T::Hash[Symbol, T.any(Date, ActiveSupport::TimeWithZone, T::Boolean)]) }
6905
+ def due_changes; end
6906
+
6907
+ sig { returns(ActiveSupport::TimeZone) }
6908
+ def zone; end
6909
+
6910
+ sig { returns(T.nilable(Date)) }
6911
+ def due_on_date; end
6912
+
6913
+ sig { returns(T.nilable(ActiveSupport::TimeWithZone)) }
6914
+ def due_at_time; end
6915
+
6916
+ # Returns the value of attribute task_gid.
6917
+ sig { returns(T.untyped) }
6918
+ attr_reader :task_gid
6919
+
6920
+ # Returns the value of attribute due_on.
6921
+ sig { returns(T.untyped) }
6922
+ attr_reader :due_on
6923
+
6924
+ # Returns the value of attribute due_at.
6925
+ sig { returns(T.untyped) }
6926
+ attr_reader :due_at
6927
+
6928
+ # Returns the value of attribute complete.
6929
+ sig { returns(T.untyped) }
6930
+ attr_reader :complete
6931
+
6932
+ # Returns the value of attribute tasks.
6933
+ sig { returns(T.untyped) }
6934
+ attr_reader :tasks
6935
+
6936
+ # Returns the value of attribute now.
6937
+ sig { returns(T.untyped) }
6938
+ attr_reader :now
6760
6939
  end
6761
6940
  end
6762
6941
 
data/sig/checkoff.rbs CHANGED
@@ -519,6 +519,23 @@ module Checkoff
519
519
 
520
520
  def default_assignee_gid: () -> String
521
521
 
522
+ # Change fields on an existing task. Asana rejects a request
523
+ # setting both due_on and due_at.
524
+ #
525
+ # _@param_ `task_gid`
526
+ #
527
+ # _@param_ `due_on`
528
+ #
529
+ # _@param_ `due_at`
530
+ #
531
+ # _@param_ `completed`
532
+ def update_task: (
533
+ String task_gid,
534
+ ?due_on: Date?,
535
+ ?due_at: (Time | ActiveSupport::TimeWithZone)?,
536
+ ?completed: bool?
537
+ ) -> Asana::Resources::Task
538
+
522
539
  def logger: () -> ::Logger
523
540
 
524
541
  # _@param_ `message`
@@ -3384,8 +3401,8 @@ module Checkoff
3384
3401
  attr_reader client: Asana::Client
3385
3402
  end
3386
3403
 
3387
- # Builds the subcommands CheckoffGLIApp runs, giving the quickadd and
3388
- # view subcommands the collaborators they accept out of those passed
3404
+ # Builds the subcommands CheckoffGLIApp runs, giving the quickadd,
3405
+ # view and update subcommands the collaborators they accept out of those passed
3389
3406
  # here; the rest fall back to the subcommand's own defaults.
3390
3407
  class SubcommandFactory
3391
3408
  # _@param_ `mv_subcommand_class`
@@ -3431,6 +3448,78 @@ module Checkoff
3431
3448
  to_project_arg: (Symbol | String),
3432
3449
  to_section_arg: (Symbol | String)?
3433
3450
  ) -> MvSubcommand
3451
+
3452
+ # _@param_ `task_gid`
3453
+ #
3454
+ # _@param_ `due_on`
3455
+ #
3456
+ # _@param_ `due_at`
3457
+ #
3458
+ # _@param_ `complete`
3459
+ def update: (
3460
+ String task_gid,
3461
+ due_on: String?,
3462
+ due_at: String?,
3463
+ complete: bool
3464
+ ) -> UpdateSubcommand
3465
+ end
3466
+
3467
+ # CLI subcommand that changes an existing task's due date or time
3468
+ # and/or marks it complete
3469
+ class UpdateSubcommand
3470
+ TIME_ZONE: untyped
3471
+
3472
+ # _@param_ `task_gid`
3473
+ #
3474
+ # _@param_ `due_on` — today, tomorrow or YYYY-MM-DD
3475
+ #
3476
+ # _@param_ `due_at` — a time such as 11:30am, on the due_on date if given, else today; or a full time such as 2026-12-02T11:30:00-05:00. Read in TIME_ZONE unless it gives an offset.
3477
+ #
3478
+ # _@param_ `complete`
3479
+ #
3480
+ # _@param_ `config`
3481
+ #
3482
+ # _@param_ `tasks`
3483
+ #
3484
+ # _@param_ `now` — the current time in TIME_ZONE
3485
+ def initialize: (
3486
+ String task_gid,
3487
+ ?due_on: String?,
3488
+ ?due_at: String?,
3489
+ ?complete: bool,
3490
+ ?config: (Checkoff::Internal::EnvFallbackConfigLoader | ::Hash[untyped, untyped]),
3491
+ ?tasks: Checkoff::Tasks,
3492
+ ?now: ActiveSupport::TimeWithZone
3493
+ ) -> void
3494
+
3495
+ def run: () -> void
3496
+
3497
+ # Asana rejects a request setting both due_on and due_at
3498
+ def due_changes: () -> ::Hash[Symbol, (Date | ActiveSupport::TimeWithZone | bool)]
3499
+
3500
+ def zone: () -> ActiveSupport::TimeZone
3501
+
3502
+ def due_on_date: () -> Date?
3503
+
3504
+ def due_at_time: () -> ActiveSupport::TimeWithZone?
3505
+
3506
+ # Returns the value of attribute task_gid.
3507
+ attr_reader task_gid: untyped
3508
+
3509
+ # Returns the value of attribute due_on.
3510
+ attr_reader due_on: untyped
3511
+
3512
+ # Returns the value of attribute due_at.
3513
+ attr_reader due_at: untyped
3514
+
3515
+ # Returns the value of attribute complete.
3516
+ attr_reader complete: untyped
3517
+
3518
+ # Returns the value of attribute tasks.
3519
+ attr_reader tasks: untyped
3520
+
3521
+ # Returns the value of attribute now.
3522
+ attr_reader now: untyped
3434
3523
  end
3435
3524
  end
3436
3525
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: checkoff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.280.0
4
+ version: 0.281.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vince Broz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-11-28 00:00:00.000000000 Z
11
+ date: 2026-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport