myask 0.0.1 → 1.1.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.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/bin/myask +1 -1
  4. data/html/App.html +116 -0
  5. data/html/MyAsk/Api/Helper.html +207 -0
  6. data/html/MyAsk/Api/Invitation.html +212 -0
  7. data/html/MyAsk/Api/Project.html +355 -0
  8. data/html/MyAsk/Api/ProjectHelper.html +299 -0
  9. data/html/MyAsk/Api/Question.html +261 -0
  10. data/html/MyAsk/Api.html +120 -0
  11. data/html/MyAsk/Config.html +195 -0
  12. data/html/MyAsk/ConfigHelper.html +251 -0
  13. data/html/MyAsk/Prompt.html +221 -0
  14. data/html/MyAsk/PromptHelper.html +330 -0
  15. data/html/MyAsk.html +114 -0
  16. data/html/README_rdoc.html +394 -0
  17. data/html/created.rid +14 -0
  18. data/html/css/fonts.css +167 -0
  19. data/html/css/rdoc.css +681 -0
  20. data/html/fonts/Lato-Light.ttf +0 -0
  21. data/html/fonts/Lato-LightItalic.ttf +0 -0
  22. data/html/fonts/Lato-Regular.ttf +0 -0
  23. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  24. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  25. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  26. data/html/images/add.png +0 -0
  27. data/html/images/arrow_up.png +0 -0
  28. data/html/images/brick.png +0 -0
  29. data/html/images/brick_link.png +0 -0
  30. data/html/images/bug.png +0 -0
  31. data/html/images/bullet_black.png +0 -0
  32. data/html/images/bullet_toggle_minus.png +0 -0
  33. data/html/images/bullet_toggle_plus.png +0 -0
  34. data/html/images/date.png +0 -0
  35. data/html/images/delete.png +0 -0
  36. data/html/images/find.png +0 -0
  37. data/html/images/loadingAnimation.gif +0 -0
  38. data/html/images/macFFBgHack.png +0 -0
  39. data/html/images/package.png +0 -0
  40. data/html/images/page_green.png +0 -0
  41. data/html/images/page_white_text.png +0 -0
  42. data/html/images/page_white_width.png +0 -0
  43. data/html/images/plugin.png +0 -0
  44. data/html/images/ruby.png +0 -0
  45. data/html/images/tag_blue.png +0 -0
  46. data/html/images/tag_green.png +0 -0
  47. data/html/images/transparent.png +0 -0
  48. data/html/images/wrench.png +0 -0
  49. data/html/images/wrench_orange.png +0 -0
  50. data/html/images/zoom.png +0 -0
  51. data/html/index.html +403 -0
  52. data/html/js/darkfish.js +120 -0
  53. data/html/js/navigation.js +105 -0
  54. data/html/js/navigation.js.gz +0 -0
  55. data/html/js/search.js +110 -0
  56. data/html/js/search_index.js +1 -0
  57. data/html/js/search_index.js.gz +0 -0
  58. data/html/js/searcher.js +229 -0
  59. data/html/js/searcher.js.gz +0 -0
  60. data/html/table_of_contents.html +257 -0
  61. data/lib/myask/prompt_helper.rb +4 -1
  62. data/lib/myask/version.rb +1 -1
  63. data/pkg/myask-0.0.1/Gemfile +10 -0
  64. data/pkg/myask-0.0.1/Gemfile.lock +70 -0
  65. data/pkg/myask-0.0.1/README.rdoc +6 -0
  66. data/pkg/myask-0.0.1/Rakefile +21 -0
  67. data/pkg/myask-0.0.1/bin/myask +101 -0
  68. data/pkg/myask-0.0.1/lib/myask/api/api_helper.rb +45 -0
  69. data/pkg/myask-0.0.1/lib/myask/api/invitation.rb +49 -0
  70. data/pkg/myask-0.0.1/lib/myask/api/project.rb +193 -0
  71. data/pkg/myask-0.0.1/lib/myask/api/project_helper.rb +46 -0
  72. data/pkg/myask-0.0.1/lib/myask/api/question.rb +99 -0
  73. data/pkg/myask-0.0.1/lib/myask/config.rb +37 -0
  74. data/pkg/myask-0.0.1/lib/myask/config_helper.rb +28 -0
  75. data/pkg/myask-0.0.1/lib/myask/prompt.rb +63 -0
  76. data/pkg/myask-0.0.1/lib/myask/prompt_helper.rb +83 -0
  77. data/pkg/myask-0.0.1/lib/myask/version.rb +3 -0
  78. data/pkg/myask-0.0.1/lib/myask.rb +28 -0
  79. data/pkg/myask-0.0.1/myask.gemspec +22 -0
  80. data/pkg/myask-0.0.1/myask.rdoc +138 -0
  81. data/pkg/myask-0.0.1/test/default_test.rb +14 -0
  82. data/pkg/myask-0.0.1/test/test_helper.rb +4 -0
  83. data/pkg/myask-0.0.1.gem +0 -0
  84. data/pkg/myask-1.0.0/Gemfile +10 -0
  85. data/pkg/myask-1.0.0/Gemfile.lock +70 -0
  86. data/pkg/myask-1.0.0/README.rdoc +6 -0
  87. data/pkg/myask-1.0.0/Rakefile +21 -0
  88. data/pkg/myask-1.0.0/bin/myask +101 -0
  89. data/pkg/myask-1.0.0/html/App.html +116 -0
  90. data/pkg/myask-1.0.0/html/MyAsk/Api/Helper.html +207 -0
  91. data/pkg/myask-1.0.0/html/MyAsk/Api/Invitation.html +212 -0
  92. data/pkg/myask-1.0.0/html/MyAsk/Api/Project.html +355 -0
  93. data/pkg/myask-1.0.0/html/MyAsk/Api/ProjectHelper.html +299 -0
  94. data/pkg/myask-1.0.0/html/MyAsk/Api/Question.html +261 -0
  95. data/pkg/myask-1.0.0/html/MyAsk/Api.html +120 -0
  96. data/pkg/myask-1.0.0/html/MyAsk/Config.html +195 -0
  97. data/pkg/myask-1.0.0/html/MyAsk/ConfigHelper.html +251 -0
  98. data/pkg/myask-1.0.0/html/MyAsk/Prompt.html +221 -0
  99. data/pkg/myask-1.0.0/html/MyAsk/PromptHelper.html +330 -0
  100. data/pkg/myask-1.0.0/html/MyAsk.html +114 -0
  101. data/pkg/myask-1.0.0/html/README_rdoc.html +394 -0
  102. data/pkg/myask-1.0.0/html/created.rid +14 -0
  103. data/pkg/myask-1.0.0/html/css/fonts.css +167 -0
  104. data/pkg/myask-1.0.0/html/css/rdoc.css +681 -0
  105. data/pkg/myask-1.0.0/html/fonts/Lato-Light.ttf +0 -0
  106. data/pkg/myask-1.0.0/html/fonts/Lato-LightItalic.ttf +0 -0
  107. data/pkg/myask-1.0.0/html/fonts/Lato-Regular.ttf +0 -0
  108. data/pkg/myask-1.0.0/html/fonts/Lato-RegularItalic.ttf +0 -0
  109. data/pkg/myask-1.0.0/html/fonts/SourceCodePro-Bold.ttf +0 -0
  110. data/pkg/myask-1.0.0/html/fonts/SourceCodePro-Regular.ttf +0 -0
  111. data/pkg/myask-1.0.0/html/images/add.png +0 -0
  112. data/pkg/myask-1.0.0/html/images/arrow_up.png +0 -0
  113. data/pkg/myask-1.0.0/html/images/brick.png +0 -0
  114. data/pkg/myask-1.0.0/html/images/brick_link.png +0 -0
  115. data/pkg/myask-1.0.0/html/images/bug.png +0 -0
  116. data/pkg/myask-1.0.0/html/images/bullet_black.png +0 -0
  117. data/pkg/myask-1.0.0/html/images/bullet_toggle_minus.png +0 -0
  118. data/pkg/myask-1.0.0/html/images/bullet_toggle_plus.png +0 -0
  119. data/pkg/myask-1.0.0/html/images/date.png +0 -0
  120. data/pkg/myask-1.0.0/html/images/delete.png +0 -0
  121. data/pkg/myask-1.0.0/html/images/find.png +0 -0
  122. data/pkg/myask-1.0.0/html/images/loadingAnimation.gif +0 -0
  123. data/pkg/myask-1.0.0/html/images/macFFBgHack.png +0 -0
  124. data/pkg/myask-1.0.0/html/images/package.png +0 -0
  125. data/pkg/myask-1.0.0/html/images/page_green.png +0 -0
  126. data/pkg/myask-1.0.0/html/images/page_white_text.png +0 -0
  127. data/pkg/myask-1.0.0/html/images/page_white_width.png +0 -0
  128. data/pkg/myask-1.0.0/html/images/plugin.png +0 -0
  129. data/pkg/myask-1.0.0/html/images/ruby.png +0 -0
  130. data/pkg/myask-1.0.0/html/images/tag_blue.png +0 -0
  131. data/pkg/myask-1.0.0/html/images/tag_green.png +0 -0
  132. data/pkg/myask-1.0.0/html/images/transparent.png +0 -0
  133. data/pkg/myask-1.0.0/html/images/wrench.png +0 -0
  134. data/pkg/myask-1.0.0/html/images/wrench_orange.png +0 -0
  135. data/pkg/myask-1.0.0/html/images/zoom.png +0 -0
  136. data/pkg/myask-1.0.0/html/index.html +403 -0
  137. data/pkg/myask-1.0.0/html/js/darkfish.js +120 -0
  138. data/pkg/myask-1.0.0/html/js/navigation.js +105 -0
  139. data/pkg/myask-1.0.0/html/js/navigation.js.gz +0 -0
  140. data/pkg/myask-1.0.0/html/js/search.js +110 -0
  141. data/pkg/myask-1.0.0/html/js/search_index.js +1 -0
  142. data/pkg/myask-1.0.0/html/js/search_index.js.gz +0 -0
  143. data/pkg/myask-1.0.0/html/js/searcher.js +229 -0
  144. data/pkg/myask-1.0.0/html/js/searcher.js.gz +0 -0
  145. data/pkg/myask-1.0.0/html/table_of_contents.html +257 -0
  146. data/pkg/myask-1.0.0/lib/myask/api/api_helper.rb +45 -0
  147. data/pkg/myask-1.0.0/lib/myask/api/invitation.rb +49 -0
  148. data/pkg/myask-1.0.0/lib/myask/api/project.rb +193 -0
  149. data/pkg/myask-1.0.0/lib/myask/api/project_helper.rb +46 -0
  150. data/pkg/myask-1.0.0/lib/myask/api/question.rb +99 -0
  151. data/pkg/myask-1.0.0/lib/myask/config.rb +37 -0
  152. data/pkg/myask-1.0.0/lib/myask/config_helper.rb +28 -0
  153. data/pkg/myask-1.0.0/lib/myask/prompt.rb +63 -0
  154. data/pkg/myask-1.0.0/lib/myask/prompt_helper.rb +83 -0
  155. data/pkg/myask-1.0.0/lib/myask/version.rb +3 -0
  156. data/pkg/myask-1.0.0/lib/myask.rb +28 -0
  157. data/pkg/myask-1.0.0/myask.gemspec +22 -0
  158. data/pkg/myask-1.0.0/myask.rdoc +138 -0
  159. data/pkg/myask-1.0.0/pkg/myask-0.0.1/Gemfile +10 -0
  160. data/pkg/myask-1.0.0/pkg/myask-0.0.1/Gemfile.lock +70 -0
  161. data/pkg/myask-1.0.0/pkg/myask-0.0.1/README.rdoc +6 -0
  162. data/pkg/myask-1.0.0/pkg/myask-0.0.1/Rakefile +21 -0
  163. data/pkg/myask-1.0.0/pkg/myask-0.0.1/bin/myask +101 -0
  164. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/api_helper.rb +45 -0
  165. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/invitation.rb +49 -0
  166. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/project.rb +193 -0
  167. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/project_helper.rb +46 -0
  168. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/api/question.rb +99 -0
  169. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/config.rb +37 -0
  170. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/config_helper.rb +28 -0
  171. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/prompt.rb +63 -0
  172. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/prompt_helper.rb +83 -0
  173. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask/version.rb +3 -0
  174. data/pkg/myask-1.0.0/pkg/myask-0.0.1/lib/myask.rb +28 -0
  175. data/pkg/myask-1.0.0/pkg/myask-0.0.1/myask.gemspec +22 -0
  176. data/pkg/myask-1.0.0/pkg/myask-0.0.1/myask.rdoc +138 -0
  177. data/pkg/myask-1.0.0/pkg/myask-0.0.1/test/default_test.rb +14 -0
  178. data/pkg/myask-1.0.0/pkg/myask-0.0.1/test/test_helper.rb +4 -0
  179. data/pkg/myask-1.0.0/pkg/myask-0.0.1.gem +0 -0
  180. data/pkg/myask-1.0.0/test/default_test.rb +14 -0
  181. data/pkg/myask-1.0.0/test/test_helper.rb +4 -0
  182. data/pkg/myask-1.0.0.gem +0 -0
  183. metadata +179 -2
@@ -0,0 +1,28 @@
1
+ module MyAsk
2
+ class ConfigHelper
3
+
4
+ def initialize(global_options, options, args)
5
+ @global_options = global_options
6
+ @options = options
7
+ @args = args
8
+ @rc_file_path = File.expand_path("~/.myask.rc")
9
+ @config_data = YAML.load_file(@rc_file_path)
10
+ end
11
+
12
+ def get_config
13
+ @config_data.reject { |key, _| ["commands", "version", "s", "help"].include?(key.to_s) }.to_json
14
+ end
15
+
16
+ def save_config
17
+ @config_data[:api_key] = @options[:api_key] if @options[:api_key]
18
+ @config_data[:api_host] = @options[:api_host] if @options[:api_host]
19
+ @config_data[:project] = @options[:project] if @options[:project]
20
+
21
+ File.open(@rc_file_path, "w") do |file|
22
+ file.write(@config_data.to_yaml)
23
+ end
24
+ @config_data.reject { |key, _| ["commands", "version", "s", "help"].include?(key.to_s) }.to_json
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,63 @@
1
+ module MyAsk
2
+ class Prompt
3
+
4
+ def initialize(c)
5
+ c.desc "Skip Follow-Up Question"
6
+ c.switch [:no_followup]
7
+
8
+ c.desc "Project ID"
9
+ c.flag [:project]
10
+
11
+ c.desc "Prompt to send"
12
+ c.flag [:p, :prompt]
13
+
14
+ c.desc "Question IDs to include in prompt context"
15
+ c.flag [:c, :context_ids], multiple: true
16
+
17
+ c.desc "Path to source file(s)"
18
+ c.flag [:F, :input_file], multiple: true
19
+
20
+ c.action do |global_options, options, args|
21
+ helper = MyAsk::PromptHelper.new(global_options, options, args)
22
+
23
+ config = global_options
24
+ auth_token = config[:api_key]
25
+ project = options[:project] || config[:project]
26
+
27
+ content = helper.get_initial_question
28
+ context_ids = options[:"context_ids"]
29
+
30
+ loop do
31
+ begin
32
+ question_id = helper.submit_question(config[:api_host], auth_token, project, content, context_ids)
33
+ abort if question_id.nil?
34
+
35
+ context_ids << question_id
36
+
37
+ response = helper.poll_for_response(config[:api_host], auth_token, question_id)
38
+
39
+ if global_options[:json]
40
+ puts "\n\n#{JSON.dump({response: response})}\n\n"
41
+ else
42
+ puts "\n\n#{response}\n\n"
43
+ end
44
+
45
+ break if options[:no_followup]
46
+
47
+ prompt = TTY::Prompt.new
48
+ is_follow_up = prompt.yes?("Would you like to ask a follow-up question?", default: false)
49
+
50
+ break unless is_follow_up
51
+
52
+ follow_up_question = prompt.ask("Enter your follow-up question:").strip
53
+ content = follow_up_question
54
+ rescue => e
55
+ abort "Error: #{e}"
56
+ end
57
+ end
58
+ end
59
+ c
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,83 @@
1
+ module MyAsk
2
+ class PromptHelper
3
+ def initialize(global_options, options, args)
4
+ @global_options = global_options
5
+ @options = options
6
+ @args = args
7
+ end
8
+
9
+ def submit_question(api_host, auth_token, project_id, content, context_ids)
10
+ uri = URI("#{api_host}/api/questions")
11
+ http = Net::HTTP.new(uri.host, uri.port)
12
+ http.use_ssl = (uri.scheme == "https")
13
+
14
+ request = Net::HTTP::Post.new(uri.path)
15
+ request["Authorization"] = "Bearer #{auth_token}"
16
+ request["Content-Type"] = "application/json"
17
+
18
+ request.body = {
19
+ question: {
20
+ project_id: project_id,
21
+ content: content,
22
+ context_ids: context_ids
23
+ }
24
+ }.to_json
25
+
26
+ response = http.request(request)
27
+ parsed_response = JSON.parse(response.body)
28
+
29
+ parsed_response['id'] || nil
30
+ end
31
+
32
+ def poll_for_response(api_host, auth_token, question_id)
33
+ unless @global_options[:silent]
34
+ spinner = TTY::Spinner.new('🔄 Waiting for response from MyAsk API... [:spinner]', format: :dots)
35
+ spinner.auto_spin
36
+ end
37
+
38
+ max_retries = 50
39
+ attempt = 0
40
+
41
+ while attempt < max_retries
42
+ sleep 3
43
+ uri = URI("#{api_host}/api/responses/#{question_id}")
44
+ response = Net::HTTP.get(uri, { 'Authorization' => "Bearer #{auth_token}" })
45
+ parsed_response = JSON.parse(response)
46
+
47
+ if parsed_response.key?('content')
48
+ spinner.success('✅ Response received!') unless @global_options[:silent]
49
+ return parsed_response['content']
50
+ end
51
+
52
+ attempt += 1
53
+ end
54
+
55
+ spinner.error('❌ Timed out waiting for MyAsk API response.') unless @global_options[:silent]
56
+ raise 'No response received from MyAsk API after multiple attempts.'
57
+ end
58
+
59
+ def get_initial_question
60
+ file_contents = []
61
+
62
+ current_directory = Dir.pwd
63
+
64
+ if @options[:input_file]&.any?
65
+ @options[:input_file].each do |file_path|
66
+ begin
67
+ file_path = file_path[0] == "/" ? file_path : "#{current_directory}/#{file_path}"
68
+ content = File.read("#{current_directory}/#{file_path}").strip
69
+ file_contents << "**File**: #{file_path}**\n#{content}"
70
+ rescue => e
71
+ raise "❌ Failed to read input file: #{file_path}"
72
+ end
73
+ end
74
+ end
75
+
76
+ combined_question = "#{@options[:prompt]}\n\n---\n#{file_contents.join("\n\n---\n")}" unless file_contents.empty?
77
+ combined_question ||= @options[:prompt] || TTY::Prompt.new.ask('Please enter a prompt:').strip
78
+
79
+ combined_question.empty? ? nil : combined_question
80
+ end
81
+
82
+ end
83
+ end
@@ -0,0 +1,3 @@
1
+ module Myask
2
+ VERSION = '1.1.0'
3
+ end
@@ -0,0 +1,28 @@
1
+ require 'myask/version.rb'
2
+
3
+ require 'myask/config.rb'
4
+ require 'myask/config_helper.rb'
5
+
6
+ require 'myask/api/api_helper.rb'
7
+
8
+ require 'myask/api/question.rb'
9
+ require 'myask/api/invitation.rb'
10
+
11
+ require 'myask/api/project.rb'
12
+ require 'myask/api/project_helper.rb'
13
+
14
+ require 'myask/prompt.rb'
15
+ require 'myask/prompt_helper.rb'
16
+
17
+ # Add requires for other files you add to your project here, so
18
+ # you just need to require this one file in your bin file
19
+
20
+ require 'net/http'
21
+ require 'json'
22
+
23
+ require 'io/console'
24
+ require 'tty-spinner'
25
+ require 'tty-prompt'
26
+ require 'yaml'
27
+
28
+ require 'pry-byebug'
@@ -0,0 +1,22 @@
1
+ # Ensure we require the local version and not one we might have installed already
2
+ require File.join([File.dirname(__FILE__),'lib','myask','version.rb'])
3
+ spec = Gem::Specification.new do |s|
4
+ s.name = 'myask'
5
+ s.version = Myask::VERSION
6
+ s.author = 'Andrew Chaney (netuoso)'
7
+ s.email = 'netuoso@myask.io'
8
+ s.homepage = 'https://myask.io'
9
+ s.platform = Gem::Platform::RUBY
10
+ s.summary = 'MyAsk Command Line Tool Integrates with MyAsk AI API (https://myask.io).'
11
+ s.files = `git ls-files`.split("
12
+ ")
13
+ s.require_paths << 'lib'
14
+ s.extra_rdoc_files = ['README.rdoc','myask.rdoc']
15
+ s.rdoc_options << '--title' << 'myask' << '--main' << 'README.rdoc' << '-ri'
16
+ s.bindir = 'bin'
17
+ s.executables << 'myask'
18
+ s.add_development_dependency('rake')
19
+ s.add_development_dependency('rdoc')
20
+ s.add_development_dependency('minitest')
21
+ s.add_runtime_dependency('gli','~> 2.22.2')
22
+ end
@@ -0,0 +1,138 @@
1
+ == myask - Describe your application here
2
+
3
+ v0.0.1
4
+
5
+ === Global Options
6
+ === --api_host arg
7
+
8
+ Host for MyAsk API
9
+
10
+ [Default Value] http://localhost:3000
11
+
12
+
13
+ === --api_key arg
14
+
15
+ API Key for MyAsk API
16
+
17
+ [Default Value] A9qVFSgXFH8Ubclq4jVYn0PBsEGMSfQf
18
+
19
+
20
+ === --project arg
21
+
22
+ Current MyAsk Project
23
+
24
+ [Default Value] 156891416
25
+
26
+
27
+ === --help
28
+ Show this message
29
+
30
+
31
+
32
+ === --[no-]json
33
+ Format Output as JSON
34
+
35
+
36
+
37
+ === --[no-]silent
38
+ Silent Progress Spinner
39
+
40
+
41
+
42
+ === --version
43
+ Display the program version
44
+
45
+
46
+
47
+ === Commands
48
+ ==== Command: <tt>config </tt>
49
+ View current or set new MyAsk configuration values
50
+
51
+
52
+ ===== Commands
53
+ ====== Command: <tt>save </tt>
54
+
55
+
56
+
57
+ ====== Command: <tt>show </tt>
58
+
59
+
60
+
61
+ [Default Command] show
62
+ ==== Command: <tt>help command</tt>
63
+ Shows a list of commands or help for one command
64
+
65
+ Gets help for the application or its commands. Can also list the commands in a way helpful to creating a bash-style completion function
66
+ ===== Options
67
+ ===== -c
68
+ List commands one per line, to assist with shell completion
69
+
70
+
71
+
72
+ ==== Command: <tt>initconfig </tt>
73
+ Initialize the config file using current global options
74
+
75
+ Initializes a configuration file where you can set default options for command line flags, both globally and on a per-command basis. These defaults override the built-in defaults and allow you to omit commonly-used command line flags when invoking this program
76
+ ===== Options
77
+ ===== --[no-]force
78
+ force overwrite of existing config file
79
+
80
+
81
+
82
+ ==== Command: <tt>invitation </tt>
83
+ Create/list MyAsk Invitations
84
+
85
+
86
+ ===== Commands
87
+ ====== Command: <tt>list </tt>
88
+ List MyAsk invitations.
89
+
90
+
91
+ ====== Command: <tt>send </tt>
92
+ Send MyAsk invitation to a new user
93
+
94
+
95
+ [Default Command] list
96
+ ==== Command: <tt>project </tt>
97
+ Create/show/list/delete MyAsk Project
98
+
99
+
100
+ ===== Commands
101
+ ====== Command: <tt>create </tt>
102
+ Create MyAsk Project
103
+
104
+
105
+ ====== Command: <tt>delete </tt>
106
+ Delete MyAsk Project
107
+
108
+
109
+ ====== Command: <tt>edit project</tt>
110
+ Edit MyAsk Project
111
+
112
+
113
+ ====== Command: <tt>set project</tt>
114
+ Set MyAsk Project
115
+
116
+
117
+ ====== Command: <tt>show project</tt>
118
+ Show MyAsk Project Details
119
+
120
+
121
+ ==== Command: <tt>prompt </tt>
122
+ Send a prompt to MyAsk API
123
+
124
+
125
+ ==== Command: <tt>question </tt>
126
+ Show/delete MyAsk Question
127
+
128
+
129
+ ===== Commands
130
+ ====== Command: <tt>delete question_id</tt>
131
+ Delete MyAsk question
132
+
133
+
134
+ ====== Command: <tt>show question_id</tt>
135
+ Show details for MyAsk question
136
+
137
+
138
+ [Default Command] show
@@ -0,0 +1,14 @@
1
+ require_relative "test_helper"
2
+
3
+ class DefaultTest < Minitest::Test
4
+
5
+ def setup
6
+ end
7
+
8
+ def teardown
9
+ end
10
+
11
+ def test_the_truth
12
+ assert true
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ require "minitest/autorun"
2
+
3
+ # Add test libraries you want to use here, e.g. mocha
4
+ # Add helper classes or methods here, too
Binary file
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
3
+
4
+ gem "json", "~> 2.10"
5
+
6
+ gem "open-uri", "~> 0.5.0"
7
+ gem "tty-spinner", "~> 0.9.3"
8
+ gem "tty-prompt", "~> 0.23.1"
9
+
10
+ gem "pry-byebug", "~> 3.11"
@@ -0,0 +1,70 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ myask (1.1.0)
5
+ gli (~> 2.22.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ byebug (12.0.0)
11
+ coderay (1.1.3)
12
+ date (3.4.1)
13
+ gli (2.22.2)
14
+ ostruct
15
+ json (2.10.2)
16
+ method_source (1.1.0)
17
+ minitest (5.25.5)
18
+ open-uri (0.5.0)
19
+ stringio
20
+ time
21
+ uri
22
+ ostruct (0.6.1)
23
+ pastel (0.8.0)
24
+ tty-color (~> 0.5)
25
+ pry (0.15.2)
26
+ coderay (~> 1.1)
27
+ method_source (~> 1.0)
28
+ pry-byebug (3.11.0)
29
+ byebug (~> 12.0)
30
+ pry (>= 0.13, < 0.16)
31
+ psych (5.2.3)
32
+ date
33
+ stringio
34
+ rake (13.2.1)
35
+ rdoc (6.13.0)
36
+ psych (>= 4.0.0)
37
+ stringio (3.1.6)
38
+ time (0.4.1)
39
+ date
40
+ tty-color (0.6.0)
41
+ tty-cursor (0.7.1)
42
+ tty-prompt (0.23.1)
43
+ pastel (~> 0.8)
44
+ tty-reader (~> 0.8)
45
+ tty-reader (0.9.0)
46
+ tty-cursor (~> 0.7)
47
+ tty-screen (~> 0.8)
48
+ wisper (~> 2.0)
49
+ tty-screen (0.8.2)
50
+ tty-spinner (0.9.3)
51
+ tty-cursor (~> 0.7)
52
+ uri (1.0.3)
53
+ wisper (2.0.1)
54
+
55
+ PLATFORMS
56
+ arm64-darwin-22
57
+
58
+ DEPENDENCIES
59
+ json (~> 2.10)
60
+ minitest
61
+ myask!
62
+ open-uri (~> 0.5.0)
63
+ pry-byebug (~> 3.11)
64
+ rake
65
+ rdoc
66
+ tty-prompt (~> 0.23.1)
67
+ tty-spinner (~> 0.9.3)
68
+
69
+ BUNDLED WITH
70
+ 2.4.22
@@ -0,0 +1,6 @@
1
+ = myask
2
+
3
+ Describe your project here
4
+
5
+ :include:myask.rdoc
6
+
@@ -0,0 +1,21 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ Rake::RDocTask.new do |rd|
6
+ rd.main = "README.rdoc"
7
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
8
+ rd.title = 'Your application title'
9
+ end
10
+
11
+ spec = Gem::Specification.load("myask.gemspec")
12
+
13
+ Gem::PackageTask.new(spec) do |pkg|
14
+ end
15
+ require 'rake/testtask'
16
+ Rake::TestTask.new do |t|
17
+ t.libs << "test"
18
+ t.test_files = FileList['test/*_test.rb']
19
+ end
20
+
21
+ task :default => :test
@@ -0,0 +1,101 @@
1
+ #!/usr/bin/env ruby
2
+ require "gli"
3
+ require "myask"
4
+
5
+ class App
6
+ extend GLI::App
7
+
8
+ config_file ".myask.rc"
9
+
10
+ program_desc "Describe your application here"
11
+
12
+ version Myask::VERSION
13
+
14
+ subcommand_option_handling :normal
15
+ arguments :strict
16
+
17
+ desc "Silent Progress Spinner"
18
+ default_value false
19
+ switch [:silent]
20
+
21
+ desc "Format Output as JSON"
22
+ default_value false
23
+ switch [:json]
24
+
25
+ desc "Host for MyAsk API"
26
+ default_value "https://myask.io"
27
+ flag [:api_host], type: String
28
+
29
+ desc "API Key for MyAsk API"
30
+ flag [:api_key], type: String
31
+
32
+ desc "Current MyAsk Project"
33
+ flag [:project], type: String
34
+
35
+ desc "View current or set new MyAsk configuration values"
36
+ command :config do |c|
37
+ MyAsk::Config.new(c)
38
+ end
39
+
40
+ desc "Send a prompt to MyAsk API"
41
+ command :prompt do |c|
42
+ MyAsk::Prompt.new(c)
43
+ end
44
+
45
+ desc "Create/show/list/delete MyAsk Project"
46
+ command :project do |c|
47
+ MyAsk::Api::Project.new(c)
48
+ end
49
+
50
+ desc "Show/delete MyAsk Question"
51
+ command :question do |c|
52
+ MyAsk::Api::Question.new(c)
53
+ end
54
+
55
+ desc "Create/list MyAsk Invitations"
56
+ command :invitation do |c|
57
+ MyAsk::Api::Invitation.new(c)
58
+ end
59
+
60
+ pre do |global,command,options,args|
61
+ unless command&.parent&.name == :config
62
+ config = global
63
+ auth_token = config[:api_key]
64
+ project = options[:project] || config[:project]
65
+
66
+ if auth_token.nil?
67
+ puts "Missing MyAsk API token. Set it using \"myask config -k YOUR_AUTH_TOKEN\"."
68
+ exit
69
+ end
70
+
71
+ if project.nil?
72
+ puts "MyAsk Project Not Set. Set it using \"myask api:project:set\"."
73
+ exit
74
+ end
75
+ end
76
+ true # false to break command
77
+ end
78
+
79
+ post do |global,command,options,args|
80
+ # Post logic here
81
+ # Use skips_post before a command to skip this
82
+ # block on that command only
83
+ end
84
+
85
+ on_error do |exception|
86
+ case exception
87
+ when TTY::Reader::InputInterrupt
88
+ abort "\n\n--- User Exit ---\n"
89
+ when SystemExit
90
+ # abort "Exited"
91
+ when Errno::ECONNREFUSED
92
+ abort "API Error: #{exception}"
93
+ else # RuntimeError
94
+ puts exception.backtrace
95
+ # binding.pry
96
+ end
97
+ false # false to skip default error handling
98
+ end
99
+ end
100
+
101
+ exit App.run(ARGV)