pike13-cli 0.1.4

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.
Files changed (88) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +196 -0
  3. data/CONTRIBUTING.md +96 -0
  4. data/LICENSE.txt +21 -0
  5. data/README.md +896 -0
  6. data/bin/pike13 +6 -0
  7. data/completions/_pike13 +229 -0
  8. data/completions/pike13.bash +112 -0
  9. data/lib/pike13/cli/commands/account/business.rb +22 -0
  10. data/lib/pike13/cli/commands/account/confirmation.rb +21 -0
  11. data/lib/pike13/cli/commands/account/password.rb +21 -0
  12. data/lib/pike13/cli/commands/account/person.rb +22 -0
  13. data/lib/pike13/cli/commands/account.rb +33 -0
  14. data/lib/pike13/cli/commands/base.rb +350 -0
  15. data/lib/pike13/cli/commands/concerns/formattable_command.rb +48 -0
  16. data/lib/pike13/cli/commands/concerns/reporting_query.rb +59 -0
  17. data/lib/pike13/cli/commands/desk/appointment.rb +58 -0
  18. data/lib/pike13/cli/commands/desk/booking.rb +56 -0
  19. data/lib/pike13/cli/commands/desk/business.rb +20 -0
  20. data/lib/pike13/cli/commands/desk/custom_field.rb +27 -0
  21. data/lib/pike13/cli/commands/desk/event.rb +32 -0
  22. data/lib/pike13/cli/commands/desk/event_occurrence.rb +64 -0
  23. data/lib/pike13/cli/commands/desk/event_occurrence_note.rb +82 -0
  24. data/lib/pike13/cli/commands/desk/event_occurrence_visit.rb +26 -0
  25. data/lib/pike13/cli/commands/desk/event_occurrence_waitlist_entry.rb +26 -0
  26. data/lib/pike13/cli/commands/desk/form_of_payment.rb +75 -0
  27. data/lib/pike13/cli/commands/desk/invoice.rb +29 -0
  28. data/lib/pike13/cli/commands/desk/location.rb +29 -0
  29. data/lib/pike13/cli/commands/desk/make_up.rb +51 -0
  30. data/lib/pike13/cli/commands/desk/note.rb +71 -0
  31. data/lib/pike13/cli/commands/desk/pack.rb +20 -0
  32. data/lib/pike13/cli/commands/desk/pack_product.rb +101 -0
  33. data/lib/pike13/cli/commands/desk/payment.rb +44 -0
  34. data/lib/pike13/cli/commands/desk/person.rb +98 -0
  35. data/lib/pike13/cli/commands/desk/person_plan.rb +27 -0
  36. data/lib/pike13/cli/commands/desk/person_visit.rb +27 -0
  37. data/lib/pike13/cli/commands/desk/person_waitlist_entry.rb +27 -0
  38. data/lib/pike13/cli/commands/desk/person_waiver.rb +27 -0
  39. data/lib/pike13/cli/commands/desk/plan.rb +29 -0
  40. data/lib/pike13/cli/commands/desk/plan_product.rb +35 -0
  41. data/lib/pike13/cli/commands/desk/punch.rb +20 -0
  42. data/lib/pike13/cli/commands/desk/refund.rb +31 -0
  43. data/lib/pike13/cli/commands/desk/revenue_category.rb +36 -0
  44. data/lib/pike13/cli/commands/desk/sales_tax.rb +36 -0
  45. data/lib/pike13/cli/commands/desk/service.rb +29 -0
  46. data/lib/pike13/cli/commands/desk/staff_member.rb +35 -0
  47. data/lib/pike13/cli/commands/desk/visit.rb +36 -0
  48. data/lib/pike13/cli/commands/desk/waitlist_entry.rb +69 -0
  49. data/lib/pike13/cli/commands/desk.rb +172 -0
  50. data/lib/pike13/cli/commands/front/appointment.rb +31 -0
  51. data/lib/pike13/cli/commands/front/booking.rb +56 -0
  52. data/lib/pike13/cli/commands/front/branding.rb +17 -0
  53. data/lib/pike13/cli/commands/front/business.rb +17 -0
  54. data/lib/pike13/cli/commands/front/event.rb +22 -0
  55. data/lib/pike13/cli/commands/front/event_occurrence.rb +35 -0
  56. data/lib/pike13/cli/commands/front/event_occurrence_note.rb +35 -0
  57. data/lib/pike13/cli/commands/front/event_occurrence_waitlist_eligibility.rb +27 -0
  58. data/lib/pike13/cli/commands/front/form_of_payment.rb +83 -0
  59. data/lib/pike13/cli/commands/front/location.rb +22 -0
  60. data/lib/pike13/cli/commands/front/person.rb +17 -0
  61. data/lib/pike13/cli/commands/front/person_plan.rb +26 -0
  62. data/lib/pike13/cli/commands/front/person_visit.rb +26 -0
  63. data/lib/pike13/cli/commands/front/person_waitlist_entry.rb +26 -0
  64. data/lib/pike13/cli/commands/front/person_waiver.rb +26 -0
  65. data/lib/pike13/cli/commands/front/plan_product.rb +31 -0
  66. data/lib/pike13/cli/commands/front/plan_terms.rb +42 -0
  67. data/lib/pike13/cli/commands/front/service.rb +22 -0
  68. data/lib/pike13/cli/commands/front.rb +113 -0
  69. data/lib/pike13/cli/commands/report/clients.rb +27 -0
  70. data/lib/pike13/cli/commands/report/enrollments.rb +27 -0
  71. data/lib/pike13/cli/commands/report/event_occurrence_staff_members.rb +31 -0
  72. data/lib/pike13/cli/commands/report/event_occurrences.rb +31 -0
  73. data/lib/pike13/cli/commands/report/invoice_item_transactions.rb +31 -0
  74. data/lib/pike13/cli/commands/report/invoice_items.rb +31 -0
  75. data/lib/pike13/cli/commands/report/invoices.rb +27 -0
  76. data/lib/pike13/cli/commands/report/monthly_business_metrics.rb +31 -0
  77. data/lib/pike13/cli/commands/report/pays.rb +27 -0
  78. data/lib/pike13/cli/commands/report/person_plans.rb +31 -0
  79. data/lib/pike13/cli/commands/report/staff_members.rb +31 -0
  80. data/lib/pike13/cli/commands/report/transactions.rb +27 -0
  81. data/lib/pike13/cli/commands/report.rb +77 -0
  82. data/lib/pike13/cli/config.rb +26 -0
  83. data/lib/pike13/cli/formatter.rb +142 -0
  84. data/lib/pike13/cli/progress.rb +85 -0
  85. data/lib/pike13/cli/thor_nested_subcommand.rb +37 -0
  86. data/lib/pike13/cli/version.rb +7 -0
  87. data/lib/pike13/cli.rb +70 -0
  88. metadata +187 -0
data/bin/pike13 ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require_relative "../lib/pike13/cli"
5
+
6
+ Pike13::CLI::Runner.start(ARGV)
@@ -0,0 +1,229 @@
1
+ #compdef pike13
2
+ # Zsh completion for pike13 CLI
3
+ # Installation:
4
+ # Copy this file to a directory in your $fpath, typically:
5
+ # cp completions/_pike13 ~/.zsh/completion/_pike13
6
+ # Then add to ~/.zshrc: fpath=(~/.zsh/completion $fpath)
7
+ # And run: autoload -U compinit && compinit
8
+
9
+ _pike13() {
10
+ local curcontext="$curcontext" state line
11
+ typeset -A opt_args
12
+
13
+ _arguments -C \
14
+ '1: :_pike13_commands' \
15
+ '2: :_pike13_subcommands' \
16
+ '3: :_pike13_operations' \
17
+ '*::arg:->args'
18
+
19
+ case $state in
20
+ args)
21
+ case $words[1] in
22
+ desk|front|account|report)
23
+ _pike13_options
24
+ ;;
25
+ esac
26
+ ;;
27
+ esac
28
+ }
29
+
30
+ _pike13_commands() {
31
+ local commands=(
32
+ 'desk:Access Desk API endpoints'
33
+ 'front:Access Front API endpoints'
34
+ 'account:Access Account API endpoints'
35
+ 'report:Access Reporting API endpoints'
36
+ 'help:Show help information'
37
+ 'version:Show version information'
38
+ )
39
+ _describe -t commands 'pike13 commands' commands
40
+ }
41
+
42
+ _pike13_subcommands() {
43
+ case $words[2] in
44
+ desk)
45
+ local desk_commands=(
46
+ 'people:Manage people'
47
+ 'events:Manage events'
48
+ 'event_occurrences:Manage event occurrences'
49
+ 'bookings:Manage bookings'
50
+ 'appointments:Manage appointments'
51
+ 'visits:Manage visits'
52
+ 'invoices:Manage invoices'
53
+ 'payments:Manage payments'
54
+ 'locations:Manage locations'
55
+ 'services:Manage services'
56
+ 'staff:Manage staff members'
57
+ 'plans:Manage plans'
58
+ 'notes:Manage person notes'
59
+ 'custom_fields:Manage custom fields'
60
+ 'revenue_categories:Manage revenue categories'
61
+ 'sales_taxes:Manage sales taxes'
62
+ 'make_ups:Manage make-ups'
63
+ 'waitlist:Manage waitlist entries'
64
+ 'person_visits:List person visits'
65
+ 'person_plans:List person plans'
66
+ 'person_waitlist:List person waitlist entries'
67
+ 'person_waivers:List person waivers'
68
+ 'forms_of_payment:Manage forms of payment'
69
+ 'help:Show help for desk commands'
70
+ )
71
+ _describe -t desk-commands 'desk commands' desk_commands
72
+ ;;
73
+ front)
74
+ local front_commands=(
75
+ 'people-me:Get current person'
76
+ 'events-list:List events'
77
+ 'event-occurrences-list:List event occurrences'
78
+ 'services-list:List services'
79
+ 'appointments-available:Find available appointments'
80
+ 'locations-list:List locations'
81
+ 'business:Get business information'
82
+ 'branding:Get branding information'
83
+ 'bookings-get:Get a booking'
84
+ 'bookings-create:Create a booking'
85
+ 'bookings-update:Update a booking'
86
+ 'bookings-delete:Delete a booking'
87
+ 'person-visits:List person visits'
88
+ 'person-plans:List person plans'
89
+ 'person-waitlist:List person waitlist entries'
90
+ 'person-waivers:List person waivers'
91
+ 'forms-of-payment-list:List forms of payment'
92
+ 'forms-of-payment-get:Get a form of payment'
93
+ 'forms-of-payment-me:Get own form of payment'
94
+ 'forms-of-payment-create:Create a form of payment'
95
+ 'forms-of-payment-update:Update a form of payment'
96
+ 'forms-of-payment-delete:Delete a form of payment'
97
+ 'help:Show help for front commands'
98
+ )
99
+ _describe -t front-commands 'front commands' front_commands
100
+ ;;
101
+ account)
102
+ local account_commands=(
103
+ 'me:Get current account user'
104
+ 'businesses:List businesses'
105
+ 'people:Manage people'
106
+ 'password-reset:Reset password'
107
+ 'help:Show help for account commands'
108
+ )
109
+ _describe -t account-commands 'account commands' account_commands
110
+ ;;
111
+ report)
112
+ local report_commands=(
113
+ 'clients:Generate clients report'
114
+ 'transactions:Generate transactions report'
115
+ 'enrollments:Generate enrollments report'
116
+ 'monthly_metrics:Generate monthly metrics report'
117
+ 'invoices:Generate invoices report'
118
+ 'event_occurrences:Generate event occurrences report'
119
+ 'event_occurrence_staff:Generate event occurrence staff report'
120
+ 'invoice_items:Generate invoice items report'
121
+ 'invoice_item_transactions:Generate invoice item transactions report'
122
+ 'pays:Generate pays report'
123
+ 'person_plans:Generate person plans report'
124
+ 'staff_members:Generate staff members report'
125
+ 'help:Show help for report commands'
126
+ )
127
+ _describe -t report-commands 'report commands' report_commands
128
+ ;;
129
+ esac
130
+ }
131
+
132
+ _pike13_operations() {
133
+ case $words[2] in
134
+ desk)
135
+ case $words[3] in
136
+ people|events|event_occurrences|locations|services|staff|plans|invoices|visits|notes|custom_fields|revenue_categories|sales_taxes|waitlist|forms_of_payment)
137
+ local operations=(
138
+ 'list:List all resources'
139
+ 'ls:Alias for list'
140
+ 'get:Get a resource by ID'
141
+ 'create:Create a new resource'
142
+ 'update:Update a resource'
143
+ 'delete:Delete a resource'
144
+ 'help:Show help for this resource'
145
+ )
146
+ _describe -t operations 'operations' operations
147
+ ;;
148
+ person_visits|person_plans|person_waitlist|person_waivers)
149
+ local operations=(
150
+ 'list:List resources for a person'
151
+ 'ls:Alias for list'
152
+ 'help:Show help for this resource'
153
+ )
154
+ _describe -t operations 'operations' operations
155
+ ;;
156
+ make_ups)
157
+ local operations=(
158
+ 'reasons:List make-up reasons'
159
+ 'generate:Generate a make-up'
160
+ 'help:Show help for make-ups'
161
+ )
162
+ _describe -t operations 'operations' operations
163
+ ;;
164
+ appointments)
165
+ local operations=(
166
+ 'available:Find available appointment slots'
167
+ 'summary:Get availability summary'
168
+ 'help:Show help for appointments'
169
+ )
170
+ _describe -t operations 'operations' operations
171
+ ;;
172
+ payments)
173
+ local operations=(
174
+ 'get:Get a payment by ID'
175
+ 'configuration:Get payment configuration'
176
+ 'void:Void a payment'
177
+ 'help:Show help for payments'
178
+ )
179
+ _describe -t operations 'operations' operations
180
+ ;;
181
+ bookings)
182
+ local operations=(
183
+ 'get:Get a booking by ID'
184
+ 'create:Create a new booking'
185
+ 'update:Update a booking'
186
+ 'delete:Delete a booking'
187
+ 'help:Show help for bookings'
188
+ )
189
+ _describe -t operations 'operations' operations
190
+ ;;
191
+ people)
192
+ local operations=(
193
+ 'list:List all people'
194
+ 'ls:Alias for list'
195
+ 'get:Get a person by ID'
196
+ 'search:Search for people'
197
+ 'me:Get current person'
198
+ 'create:Create a new person'
199
+ 'update:Update a person'
200
+ 'delete:Delete a person'
201
+ 'help:Show help for people'
202
+ )
203
+ _describe -t operations 'operations' operations
204
+ ;;
205
+ staff)
206
+ local operations=(
207
+ 'list:List all staff'
208
+ 'ls:Alias for list'
209
+ 'get:Get a staff member by ID'
210
+ 'me:Get current staff user'
211
+ 'help:Show help for staff'
212
+ )
213
+ _describe -t operations 'operations' operations
214
+ ;;
215
+ esac
216
+ ;;
217
+ esac
218
+ }
219
+
220
+ _pike13_options() {
221
+ _arguments \
222
+ '--format[Output format]:format:(json table csv)' \
223
+ '--compact[Compact output]' \
224
+ '--color[Enable color output]' \
225
+ '--help[Show help]' \
226
+ '-h[Show help]'
227
+ }
228
+
229
+ _pike13 "$@"
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env bash
2
+ # Bash completion for pike13 CLI
3
+ # Installation:
4
+ # Copy this file to /etc/bash_completion.d/ or source it in your ~/.bashrc:
5
+ # source /path/to/pike13-cli/completions/pike13.bash
6
+
7
+ _pike13_completion() {
8
+ local cur prev opts base
9
+ COMPREPLY=()
10
+ cur="${COMP_WORDS[COMP_CWORD]}"
11
+ prev="${COMP_WORDS[COMP_CWORD-1]}"
12
+
13
+ # Get the base command (pike13)
14
+ base="${COMP_WORDS[0]}"
15
+
16
+ # Top-level commands
17
+ local commands="desk front account report help version"
18
+
19
+ # Desk subcommands
20
+ local desk_commands="people events event_occurrences bookings appointments visits invoices payments locations services staff plans notes custom_fields revenue_categories sales_taxes make_ups waitlist person_visits person_plans person_waitlist person_waivers forms_of_payment help"
21
+
22
+ # Front subcommands
23
+ local front_commands="people-me events-list event-occurrences-list services-list appointments-available locations-list business branding bookings-get bookings-create bookings-update bookings-delete person-visits person-plans person-waitlist person-waivers forms-of-payment-list forms-of-payment-get forms-of-payment-me forms-of-payment-create forms-of-payment-update forms-of-payment-delete help"
24
+
25
+ # Account subcommands
26
+ local account_commands="me businesses people password-reset help"
27
+
28
+ # Report subcommands
29
+ local report_commands="clients transactions enrollments monthly_metrics invoices event_occurrences event_occurrence_staff invoice_items invoice_item_transactions pays person_plans staff_members help"
30
+
31
+ # Resource operations (used by most resources)
32
+ local resource_ops="list ls get create update delete help"
33
+
34
+ # Common options
35
+ local format_opts="--format --compact --color"
36
+ local common_opts="--help -h"
37
+
38
+ # Handle completion based on position
39
+ case "${COMP_CWORD}" in
40
+ 1)
41
+ # Complete top-level commands
42
+ COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
43
+ return 0
44
+ ;;
45
+ 2)
46
+ # Complete subcommands based on namespace
47
+ case "${prev}" in
48
+ desk)
49
+ COMPREPLY=( $(compgen -W "${desk_commands}" -- ${cur}) )
50
+ return 0
51
+ ;;
52
+ front)
53
+ COMPREPLY=( $(compgen -W "${front_commands}" -- ${cur}) )
54
+ return 0
55
+ ;;
56
+ account)
57
+ COMPREPLY=( $(compgen -W "${account_commands}" -- ${cur}) )
58
+ return 0
59
+ ;;
60
+ report)
61
+ COMPREPLY=( $(compgen -W "${report_commands}" -- ${cur}) )
62
+ return 0
63
+ ;;
64
+ esac
65
+ ;;
66
+ 3)
67
+ # Complete resource operations for desk commands
68
+ if [ "${COMP_WORDS[1]}" = "desk" ]; then
69
+ case "${prev}" in
70
+ people|events|event_occurrences|locations|services|staff|plans|invoices|visits|notes|custom_fields|revenue_categories|sales_taxes|waitlist|forms_of_payment)
71
+ COMPREPLY=( $(compgen -W "${resource_ops}" -- ${cur}) )
72
+ return 0
73
+ ;;
74
+ bookings)
75
+ COMPREPLY=( $(compgen -W "get create update delete help" -- ${cur}) )
76
+ return 0
77
+ ;;
78
+ person_visits|person_plans|person_waitlist|person_waivers)
79
+ COMPREPLY=( $(compgen -W "list ls help" -- ${cur}) )
80
+ return 0
81
+ ;;
82
+ make_ups)
83
+ COMPREPLY=( $(compgen -W "reasons generate help" -- ${cur}) )
84
+ return 0
85
+ ;;
86
+ appointments|payments)
87
+ COMPREPLY=( $(compgen -W "available summary get configuration void help" -- ${cur}) )
88
+ return 0
89
+ ;;
90
+ esac
91
+ fi
92
+ ;;
93
+ esac
94
+
95
+ # Complete options (--format, --compact, --color, etc.)
96
+ if [[ ${cur} == -* ]]; then
97
+ case "${prev}" in
98
+ --format)
99
+ COMPREPLY=( $(compgen -W "json table csv" -- ${cur}) )
100
+ return 0
101
+ ;;
102
+ *)
103
+ COMPREPLY=( $(compgen -W "${format_opts} ${common_opts}" -- ${cur}) )
104
+ return 0
105
+ ;;
106
+ esac
107
+ fi
108
+
109
+ return 0
110
+ }
111
+
112
+ complete -F _pike13_completion pike13
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module CLI
5
+ module Commands
6
+ class Account < Base
7
+ class Business < Base
8
+ desc "list", "List all businesses for the account"
9
+ format_options
10
+ def list
11
+ handle_error do
12
+ result = with_progress("Fetching businesses") do
13
+ Pike13::Account::Business.all
14
+ end
15
+ output(result)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module CLI
5
+ module Commands
6
+ class Account < Base
7
+ class Confirmation < Base
8
+ desc "create", "Create confirmation with token"
9
+ format_options
10
+ option :token, type: :string, required: true, desc: "Confirmation token"
11
+ def create
12
+ handle_error do
13
+ result = Pike13::Account::Confirmation.create(confirmation_token: options[:token])
14
+ output(result)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module CLI
5
+ module Commands
6
+ class Account < Base
7
+ class Password < Base
8
+ desc "reset", "Request password reset"
9
+ format_options
10
+ option :email, type: :string, required: true
11
+ def reset
12
+ handle_error do
13
+ result = Pike13::Account::Password.create(email: options[:email])
14
+ output(result)
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Pike13
4
+ module CLI
5
+ module Commands
6
+ class Account < Base
7
+ class Person < Base
8
+ desc "list", "List all people across businesses"
9
+ format_options
10
+ def list
11
+ handle_error do
12
+ result = with_progress("Fetching people") do
13
+ Pike13::Account::Person.all
14
+ end
15
+ output(result)
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base"
4
+ require_relative "account/business"
5
+ require_relative "account/person"
6
+ require_relative "account/password"
7
+ require_relative "account/confirmation"
8
+
9
+ module Pike13
10
+ module CLI
11
+ module Commands
12
+ class Account < Base
13
+ desc "me", "Get current account"
14
+ format_options
15
+ def me
16
+ handle_error { output(Pike13::Account.me) }
17
+ end
18
+
19
+ desc "businesses SUBCOMMAND", "Manage businesses"
20
+ subcommand "businesses", Account::Business
21
+
22
+ desc "people SUBCOMMAND", "Manage people"
23
+ subcommand "people", Account::Person
24
+
25
+ desc "password SUBCOMMAND", "Manage password"
26
+ subcommand "password", Account::Password
27
+
28
+ desc "confirmation SUBCOMMAND", "Manage account confirmation"
29
+ subcommand "confirmation", Account::Confirmation
30
+ end
31
+ end
32
+ end
33
+ end