atk_toolbox 0.0.105 → 0.0.106

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a0227d1d4c7c02fb3fd5b05488dc8427a00842510cc6aca8fd2334461db7992
4
- data.tar.gz: 4f2d3a17a04671ba81034e58d039fe236d619bdcaaa30d075f55f4cad55630dd
3
+ metadata.gz: 92a0b43317388c1747b105aa93b15f70a20c829ad86d439120300c8604856284
4
+ data.tar.gz: 2ce1e06771e1b7cc4900269f5275ba87f32f7ca4d8afb93a236a64ba293ab36a
5
5
  SHA512:
6
- metadata.gz: 2b2026e33762fff5627d8cef175babdca7134a3d26cc190453db36209ab53cebaf15ed1f96b312a71939c9ad8f7dbb2b2dd6a74a41d99e6d901f466b484c0cac
7
- data.tar.gz: 2dc8daf6aa386bd54c0bbb16b70d0012e717afd54afa9540611c40d8c328f1c38c3244bb7ecdf065bc6a77319cbed88170c2c7a44c086443bdaccb3dd943ba0c
6
+ metadata.gz: 24a92ce26535d23bbe3b38cad85d7d2b72fcab80af72d33fd6c9d1bda2471ee4ae0e1e0f1531cebb6f1ab22ce89448aeb928125f4940b65f3218bdc1d72f885c
7
+ data.tar.gz: 672dcb0e0bd74af7dac51904f298fa85ceb67a7297135b3ea0d0d78c2b091904481655c83a8ccf96187c2500887c088a45c06bf090b85c1c31e2f94e17a093ef
data/lib/atk/atk_info.rb CHANGED
@@ -161,4 +161,8 @@ module ATK
161
161
  puts "\ndon't forget to do:\n#{"cd '#{project_path}'".blue}"
162
162
  end
163
163
  end
164
+
165
+ def not_yet_implemented()
166
+ puts "Sorry, this feature is still under development"
167
+ end
164
168
  end
@@ -0,0 +1,166 @@
1
+ require_relative '../atk_info'
2
+
3
+ module ATK
4
+ def self.project(args)
5
+ # TODO: check to make sure project exists
6
+ if args.length == 0
7
+ puts "if you don't know how to use #{"project".blue} just run #{"project help".blue}"
8
+ puts ""
9
+ # if there are commands then show them
10
+ begin
11
+ commands = Info.project_commands
12
+ if commands.is_a?(Hash) && commands.keys.size > 0
13
+ puts "commands for current project:"
14
+ puts `project commands`
15
+ end
16
+ rescue => exception
17
+ end
18
+ else
19
+ #
20
+ # Check dependencies
21
+ #
22
+ # if they're not met, then warn the user about that
23
+ # check a hash of the file to see if anything has changed
24
+ case args[0]
25
+ when 'help', '--help', '-h'
26
+ puts <<-HEREDOC.remove_indent
27
+ #{"help".yellow}
28
+ #{"info:".green} displays the avalible tools
29
+ #{"examples:".green} #{'project help'.blue}
30
+
31
+ #{"initialize".yellow}
32
+ #{"examples:".green}
33
+ #{'project init'.blue}
34
+ #{'project initialize'.blue}
35
+ #{"info:".green}
36
+ This will create an info.yaml in your current directory
37
+ The info.yaml will contain all the standard project managment tools
38
+ In the future this command will be more interactive
39
+
40
+ #{"synchronize".yellow}
41
+ #{"examples:".green}
42
+ #{'project sync'.blue}
43
+ #{'project synchronize'.blue}
44
+ #{'project synchronize --message=\'updated the readme\''.blue}
45
+ #{"info:".green}
46
+ Adds, commits, and then pulls/pushes all git changes
47
+ If there is merge conflict, it will show up as normal
48
+ #{"format:".green}
49
+ #{"project".blue} #{"synchronize".yellow} #{"<package>".cyan} #{"--message='your message'".light_magenta}
50
+
51
+ #{"execute".yellow}
52
+ #{"examples:".green}
53
+ #{'project execute compile'.blue}
54
+ #{'project exec compile'.blue}
55
+ #{'project exec main'.blue}
56
+ #{'project exec server'.blue}
57
+ #{"info:".green}
58
+ This will look at the info.yaml file in your project to find commands
59
+ You can use the `project init` command to generate an info.yaml which
60
+ has example commands. Commands can be CMD/terminal/console commands, or ruby code.
61
+ #{"format:".green}
62
+ #{"project".blue} #{"execute".yellow} #{"<name-of-command>".cyan} #{"<arg1-for-command>".light_magenta} #{"<arg2-for-command>".light_magenta} #{"<...etc>".light_magenta}
63
+
64
+ #{"commands".yellow}
65
+ #{"examples:".green} #{'project commands'.blue}
66
+ #{"info:".green}
67
+ This will read the local info.yaml of your project to find commands
68
+ then it will list out each command with a short preview of the contents of that command
69
+ HEREDOC
70
+ when 'initialize', 'init'
71
+ Info.init
72
+ when 'synchronize', 'sync'
73
+ # if there is an argument
74
+ git_folder_path = FS.dirname(Info.source_path)/".git"
75
+ if not FS.is_folder(git_folder_path)
76
+ raise <<-HEREDOC.remove_indent
77
+
78
+
79
+ The `project sync` command was called inside of #{FS.dirname(Info.source_path)}
80
+ However, there doesn't seem to be a git repository in this folder
81
+ (and changes can't be saved/synced without a git repository)
82
+ HEREDOC
83
+ end
84
+ message = args[1]
85
+ if message == nil
86
+ message = ""
87
+ else
88
+ if not message.start_with?('--message=')
89
+ raise "\n\nWhen giving arguments to the sync command, please give your message as:\n\n project sync --message='whatever you wanted to say'"
90
+ else
91
+ # remove the begining of the message
92
+ message = args[1].sub(/^--message=/,"")
93
+ # remove leading/trailing whitespace
94
+ message.strip!
95
+ end
96
+ end
97
+ if message.size == 0
98
+ message = '-'
99
+ end
100
+
101
+ # add everything
102
+ system('git add -A')
103
+ # commit everything
104
+ system('git', 'commit', '-m', message)
105
+ # pull down everything
106
+ system('git pull --no-edit')
107
+ # push up everything
108
+ system('git push')
109
+
110
+ when 'mix'
111
+ not_yet_implemented()
112
+ structure_name = args[1]
113
+ # use this to mix a structure into the project
114
+ # TODO:
115
+ # get the context
116
+ # if there is a --context='something' command line option, then use that
117
+ # otherwise use the default(--context) speficied in the info.yaml
118
+ # re-iterate through the info.yaml (advanced_setup) keys
119
+ # find all of the "when(--context = 'something')" keys
120
+ # find the (dependencies) sub-key for them, create one if the key doesn't exist
121
+ # add the project and version to the
122
+ when 'add'
123
+ not_yet_implemented()
124
+ package = args[1]
125
+ # check if there is an info.yaml
126
+ # check if there is an local_package_manager in the info.yaml
127
+ # if there is only 1, then use it
128
+ # if there is more than one, ask which one the user wants to use
129
+ when 'remove'
130
+ not_yet_implemented()
131
+ package = args[1]
132
+ # check if there is an local_package_manager in the info.yaml
133
+ # if it does use it to remove the package
134
+ when 'execute', 'exec'
135
+ # extract the (project_commands) section from the info.yaml,
136
+ # then find the command with the same name as args[1] and run it
137
+ # TODO: use https://github.com/piotrmurach/tty-markdown#ttymarkdown- to highlight the ruby code
138
+ _, command_name, *command_args = args
139
+ command = Info.project_commands[command_name]
140
+ # temporairly set the dir to be the same as the info.yaml
141
+ FS.in_dir(Info.folder()) do
142
+ if command.is_a?(String)
143
+ -(command+' '+command_args.join(' '))
144
+ elsif command.is_a?(Code)
145
+ command.run(*command_args)
146
+ elsif command == nil
147
+ puts "I don't think that command is in the info.yaml file"
148
+ end
149
+ end
150
+ when 'commands'
151
+ max_number_of_chars_to_show = 80
152
+ commands = Info.project_commands
153
+ if commands.keys.size == 0
154
+ puts "0 avalible commands".cyan
155
+ else
156
+ for each_key, each_value in commands
157
+ puts " #{each_key.to_s.yellow}: #{each_value.to_s.strip[0..max_number_of_chars_to_show].sub(/(.*)[\s\S]*/,'\1')}"
158
+ end
159
+ end
160
+ else
161
+ puts "I don't recognized that command\nhere's the `project --help` which might get you what you're looking for:"
162
+ ATK.project(["help"])
163
+ end
164
+ end
165
+ end
166
+ end
@@ -6,6 +6,8 @@ require_relative './extra_yaml'
6
6
  require 'fileutils'
7
7
  require_relative './remove_indent.rb'
8
8
 
9
+ # TODO: for efficiency, have the parser generate a parsed object, instead of only handling everything dynamically (allow for both)
10
+
9
11
  #
10
12
  # Create loaders for ruby code literal and console code literal
11
13
  #
@@ -1,3 +1,3 @@
1
1
  module AtkToolbox
2
- VERSION = '0.0.105'
2
+ VERSION = '0.0.106'
3
3
  end
data/lib/atk_toolbox.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # require all the ruby files
2
- files = Dir.glob(File.join(__dir__, "atk", "*.rb"))
2
+ files = Dir.glob(File.join(__dir__, "atk", "**/*.rb"))
3
3
  for each in files
4
4
  require_relative each
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atk_toolbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.105
4
+ version: 0.0.106
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Hykin
@@ -97,6 +97,7 @@ extensions: []
97
97
  extra_rdoc_files: []
98
98
  files:
99
99
  - lib/atk/atk_info.rb
100
+ - lib/atk/commands/project.rb
100
101
  - lib/atk/console.rb
101
102
  - lib/atk/default_info.yaml
102
103
  - lib/atk/extra_yaml.rb