arli 1.0.2 → 1.1.0

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
  SHA1:
3
- metadata.gz: adcc3fbbb5dd94f24a30c1662c9770bb010eab0e
4
- data.tar.gz: 3ac5b432418cf52430e664b5409e9377f83959ab
3
+ metadata.gz: 818b4b5c9c83de430b9c59f4487731ee42cca089
4
+ data.tar.gz: 8a2bce6807e0a4a84245d62bcc0780386bd46244
5
5
  SHA512:
6
- metadata.gz: 4301495fc38c55dc8ce4a4dc4062b87e87bb325ab40c7607427a9650d2b135cf7e78a6e693211e44428cae27ae8bc40965add0784e9deb5f7548c82571bea007
7
- data.tar.gz: d9f2ff1345a4d6205b1258e4a81574bb58496386526a60700aaea95637113fadd293dd3edcaf0bef175890b807a4362fbd1c0619b2255161c4b29031a8f19e0d
6
+ metadata.gz: a8eae4bcea44a72f7fe9411ac2efe3c8eec1de049b44f5829620a3d9255ee351738919c855134e4060f1931102a37b11c95abbcb0bc32b9a6fdbd878bd78ab4a
7
+ data.tar.gz: 8f28ec1d5c3e7ad1736ac89e3be18fe9bd003f5ddc10f908e3547cf226a34437fd89f614fe375439b0052798668bc7876277088486be33297eba51e130a1257b
data/README.md CHANGED
@@ -21,6 +21,10 @@ Arli can:
21
21
 
22
22
  * **search for Arduino libraries** in the official public [database](http://downloads.arduino.cc/libraries/library_index.json.gz) maintained by Arduino using any library attribute by exact match, or regular expression, substring, and more.
23
23
 
24
+ To get a sense of its feature, we invite you to watch the following screen cast:
25
+
26
+ [![asciicast](https://asciinema.org/a/155261.png)](https://asciinema.org/a/155261)
27
+
24
28
  ### Who is Arli For?
25
29
 
26
30
  _Arli is ideally suited for C/C++ programmers who have some basic knowledge of CMake, and who want to build larger-than-trivial projects on Arduino platform. Arli promotes use and reuse of libraries, which help take advantage of the Object Oriented Design Patterns, decoupling your code into reusable libraries._
@@ -5,11 +5,13 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
  require 'arli/version'
6
6
 
7
7
  Arli::DESCRIPTION = <<-eof
8
- This is an Arduino Library manager, compatible with the "arduino-cmake" project.
9
- Arli offers a powerful command-line tool to manage any number of dependent Github
10
- projects, or official Arduino libraries. Arli was created to offer Arduino-based
11
- projects of moderate to high complexity an easy way to reference external libraries
12
- and install them at build time, instead of committing them into the project repo.
8
+ This is an Arduino helper toolkit that builds on top of the arduino-cmake
9
+ project a powerful alternative build system for Arduino. What Arli provides
10
+ is capability to search for libraries by any attributes and regular expressions,
11
+ install a whole set of libraries defined in a YAML file Arlifile, and finally,
12
+ it can generate a brand new Sketch Project based on arduino-cmake, that builds
13
+ out the box. Arli is a command line tool, so run "arli" after installing the gem
14
+ for more information.
13
15
  eof
14
16
 
15
17
  Gem::Specification.new do |spec|
@@ -40,7 +40,7 @@ module Arli
40
40
  return nil unless non_flag_argument?
41
41
  cmd = argv.shift.to_sym
42
42
  if factory.valid_command?(cmd)
43
- cmd
43
+ factory.command_from_arg(cmd)
44
44
  else
45
45
  raise_invalid_arli_command!(cmd)
46
46
  end
@@ -140,7 +140,7 @@ module Arli
140
140
  output_examples(command_hash[:examples]) if command_hash && command_hash[:examples]
141
141
  output_command_help if commands
142
142
  output_help
143
-
143
+ output_command_aliases(command_name) if command_name
144
144
  print_version_copyright
145
145
  end
146
146
  end
@@ -246,9 +246,12 @@ See #{Arli::Configuration::ARLI_COMMAND.blue + ' command '.green + '--help'.yell
246
246
  ' © 2017 Konstantin Gredeskoul, MIT License.'.dark unless Arli.config.quiet
247
247
  end
248
248
 
249
+ def indent
250
+ ' '
251
+ end
252
+
249
253
  def output_command_description(command_name)
250
254
  command_hash = factory.command_parsers[command_name]
251
- indent = ' '
252
255
 
253
256
  if command_hash
254
257
  if command_hash.description
@@ -265,6 +268,16 @@ See #{Arli::Configuration::ARLI_COMMAND.blue + ' command '.green + '--help'.yell
265
268
 
266
269
  command_hash
267
270
  end
271
+
272
+ private
273
+ def output_command_aliases(command_name)
274
+ command_aliases = factory.command_aliases(command_name) || []
275
+ unless command_aliases.empty?
276
+ header 'Aliases'
277
+ output indent + command_aliases.join(', ').bold.blue
278
+ output << ''
279
+ end
280
+ end
268
281
  end
269
282
  end
270
283
  end
@@ -35,7 +35,7 @@ module Arli
35
35
 
36
36
  def command_parsers
37
37
  @command_parsers ||= {
38
- search: Hashie::Mash.new(
38
+ search: Hashie::Mash.new(
39
39
  {
40
40
  sentence: 'Search standard Arduino Library Database with over 4K entries ',
41
41
  description: %Q[This command provides both the simple name-based search interface,
@@ -75,7 +75,7 @@ module Arli
75
75
  }
76
76
  }),
77
77
 
78
- generate: Hashie::Mash.new(
78
+ generate: Hashie::Mash.new(
79
79
  {
80
80
  sentence: 'Generates a new Arduino project with Arlifile',
81
81
 
@@ -107,24 +107,24 @@ module Arli
107
107
  }
108
108
  }),
109
109
 
110
- bundle: Hashie::Mash.new(
110
+ bundle: Hashie::Mash.new(
111
111
  {
112
- sentence: 'Installs all libraries specified in Arlifile',
112
+ sentence: 'Installs all libraries specified in Arlifile',
113
113
  description: %Q[This command reads #{'Arlifile'.bold.green} (from the current folder, by default),
114
114
  and then it installs all dependent libraries specified there, checking if
115
115
  each already exists, and if not — downloading them, and installing them into
116
116
  your Arduino Library folder. Both the folder with the Arlifile, as well as the
117
117
  destination library path folder can be changed with the command line flags.
118
118
  ],
119
- example: [
120
- { desc: 'Install all libs defined in Arlifile:',
121
- cmd: 'arli bundle ' },
119
+ example: [
120
+ { desc: 'Install all libs defined in Arlifile:',
121
+ cmd: 'arli bundle ' },
122
122
 
123
- { desc: 'Custom Arlifile location, and destination path:',
124
- cmd: 'arli bundle -a ./src -l ./libraries' }
125
- ],
123
+ { desc: 'Custom Arlifile location, and destination path:',
124
+ cmd: 'arli bundle -a ./src -l ./libraries' }
125
+ ],
126
126
 
127
- parser: -> (command_name) {
127
+ parser: -> (command_name) {
128
128
  make_parser(command_name) do |parser|
129
129
  parser.banner = usage_line 'bundle'
130
130
  parser.option_bundle
@@ -132,7 +132,7 @@ module Arli
132
132
  end
133
133
  } }),
134
134
 
135
- install: Hashie::Mash.new(
135
+ install: Hashie::Mash.new(
136
136
  {
137
137
  sentence: 'Installs a single library either by searching, or url or local ZIP',
138
138
  description: %Q[This command installs a single library into your library path
@@ -160,17 +160,41 @@ module Arli
160
160
  }
161
161
  end
162
162
 
163
+ def aliases
164
+ {
165
+ s: :search,
166
+ ser: :search,
167
+ i: :install,
168
+ ins: :install,
169
+ g: :generate,
170
+ gen: :generate,
171
+ b: :bundle,
172
+ bun: :bundle
173
+ }
174
+ end
175
+
176
+ def command_aliases(cmd)
177
+ aliases.keys.select { |k| aliases[k] == cmd }
178
+ end
163
179
 
164
180
  def commands
165
181
  command_parsers.keys
166
182
  end
167
183
 
168
184
  def valid_command?(command)
169
- commands.include?(command)
185
+ commands.include?(command) || aliases[command]
186
+ end
187
+
188
+ def command_from_arg(arg)
189
+ if commands.include?(arg)
190
+ arg
191
+ elsif aliases[arg]
192
+ aliases[arg]
193
+ end
170
194
  end
171
195
 
172
196
  def command_parser(cmd)
173
- cmd_hash = command_parsers[cmd]
197
+ cmd_hash = command_parsers[cmd] || command_parsers[aliases[cmd]]
174
198
  cmd_hash ? cmd_hash[:parser].call(cmd) : nil
175
199
  end
176
200
 
@@ -15,7 +15,6 @@ module Arli
15
15
 
16
16
  attr_accessor :settings, :dir
17
17
 
18
-
19
18
  def setup
20
19
  config.generate.project_name = config.runtime.argv.first
21
20
 
@@ -32,40 +31,45 @@ module Arli
32
31
  def run
33
32
  Dir.chdir(workspace) do
34
33
  run_with_info(
35
- "grabbing the template from\n • #{template_repo.bold.green}...",
34
+ "Grabbing the template from\n • #{template_repo.bold.green}...",
36
35
  "git clone -v #{template_repo} #{project_name} 2>&1"
37
36
  )
38
37
  Dir.chdir(project_name) do
39
38
  FileUtils.rm_rf('.git')
40
39
  FileUtils.rm_rf('example')
41
40
  run_with_info(
42
- "configuring the new project #{project_name.bold.yellow}",
41
+ "Configuring the new project #{project_name.bold.yellow}",
43
42
  'git init .'
44
43
  )
45
- run_with_info('customizing your README and other files...')
44
+ run_with_info('Customizing your README and other files...')
46
45
  rename_files!
47
46
  configure_template!
48
47
  run_with_info(
49
- 'running bin/build — to setup and build the project',
48
+ 'Running setup of the dependencies...',
49
+ 'bin/setup'
50
50
  )
51
- system('bin/build setup')
52
- puts '[OK]'.bold.green
51
+ run_with_info("The project #{project_name.bold.yellow} is ready.\n" +
52
+ 'Follow README.md for build instructions.')
53
53
  end
54
54
  end
55
+ __pt hr
55
56
  end
56
57
 
57
58
  def run_with_info(message, command = nil)
58
- info("\n" + message.cyan)
59
+ indent = ' '
60
+ ok_indent = indent + ' ✔ '.green
61
+ err_indent = indent + ' X '.red
62
+ info("\n" + message.magenta)
59
63
  return unless command
60
- o, e, s = run_system_command(command)
61
- ok_indent = ' ✔ '.green
62
- err_indent = ' x '.red
64
+ info(indent + command.bold.yellow)
65
+ o, e, s = run_system_command(command)
63
66
  info(ok_indent + o.chomp.gsub(/\n/, "\n#{ok_indent}").blue) if o && o.chomp != ''
64
67
  warn(err_indent + +e.chomp.gsub(/\n/, "\n#{err_indent}").red) if e && e.chomp != ''
65
68
  end
66
69
 
67
70
  def additional_info
68
- "\nGenerating project #{project_name.bold.green}\nDestination: #{workspace.bold.yellow}\n"
71
+ "\nGenerating project #{project_name.bold.green} into #{workspace.bold.yellow}\n" +
72
+ "Template: #{template_repo.bold.red}\n"
69
73
  end
70
74
 
71
75
  private
@@ -74,22 +78,21 @@ module Arli
74
78
  FileUtils.mv('README.md', 'README-Arli-CMake.md')
75
79
  Dir.chdir('src') do
76
80
  FileUtils.mv('MyProject.cpp', "#{project_name}.cpp")
77
- run_system_command "sed -i 's/MyProject/#{project_name}/g' CMakeLists.txt"
81
+ run_with_info('Updating CMakeLists.txt file...',
82
+ "sed -i 's/MyProject/#{project_name}/g' CMakeLists.txt")
78
83
  end
79
- run_system_command "sed -i 's/MyProject/#{project_name}/g' CMakeLists.txt"
84
+ run_with_info('Updating CMakeLists.txt file...',
85
+ "sed -i 's/MyProject/#{project_name}/g' CMakeLists.txt")
80
86
  end
81
87
 
82
88
  def configure_template!
83
89
  File.open('README.md', 'w') do |f|
84
90
  f.write <<-EOF
85
91
 
86
-
87
- > This project has been auto-generated using:
92
+ > **NOTE**: This project has been auto-generated using:
88
93
  >
89
94
  > * [arli](https://github.com/kigster/arli) Arduino toolkit, and using the `generate` command. Thank you for using Arli!
90
- >
91
95
  > * [arli-cmake](https://github.com/kigster/arli-cmake) is the template project that was used as a source for this one.
92
- >
93
96
  > * [arduino-cmake](https://github.com/arduino-cmake/arduino-cmake) is the CMake-based build system for Arduino projects.
94
97
  >
95
98
  > There is a discussion board for Arli/CMake-based projects. Please join if you have any questions or suggestions!
@@ -112,25 +115,6 @@ module Arli
112
115
 
113
116
  ## Building #{project_name}
114
117
 
115
- ### Using the BASH Helper `bin/build`
116
-
117
- This project contains a BASH script that can automate your setup and build process. The following script takes care of most dependencies, including a missing Ruby.
118
-
119
- ```bash
120
- $ cd ~/workspace/#{project_name}
121
- $ bin/build [ setup | clean | make-flags ]
122
- ```
123
-
124
- You should see a bunch of output, and upon completion, run `arli` without arguments to see if the command got installed and shows you proper help message. If you get `command not found`, please `[sudo] gem install arli --no-ri --no-rdoc`. Add sudo if your ruby installation is the system one, ie, `which ruby` returns `/usr/bin/ruby`.
125
-
126
-
127
- ### Manual Build
128
-
129
- If you prefer to have more control over the build, you can of course build manually,
130
- and manage `CMakeLists.txt` however you want.
131
-
132
- Once you've run the setup, the manual build is:
133
-
134
118
  ```bash
135
119
  $ cd ~/workspace/#{project_name}
136
120
  $ rm -rf build && mkdir -p build && cd build
@@ -141,7 +125,7 @@ $ # this next command opens a serial port monitor inside a screen session
141
125
  $ make #{project_name}-serial
142
126
  ```
143
127
 
144
- #### Customizing the Build
128
+ ### Customizing the Build
145
129
 
146
130
  You can use environment variables to set the board, CPU and the port. Simply prefix the following variables before you run `cmake ..`
147
131
 
@@ -163,6 +147,22 @@ Go ahead and edit that file, and under `dependencies:` you want to list all of y
163
147
 
164
148
  The best way to do that is to **first search for the library** using the `arli search terms` command. Once you find the library you want, just copy it's name as is into `Arlifile`. If it contains spaces, put quotes around it.
165
149
 
150
+ For example:
151
+
152
+ ```bash
153
+ ❯ arli search /adafruit.*bmp085/i
154
+
155
+ Arli (1.0.2), Command: search
156
+ Library Path: ~/Documents/Arduino/Libraries
157
+
158
+ Adafruit BMP085 Library (1.0.0) ( 1 total versions )
159
+ Adafruit BMP085 Unified (1.0.0) ( 1 total versions )
160
+ ———————————————————————
161
+ Total Versions : 2
162
+ Unique Libraries : 2
163
+ ———————————————————————
164
+ ```
165
+
166
166
  If the library is not in the official database, just add it with a name and a url. Arli will use the url field to fetch it.
167
167
 
168
168
  To verify that your Arlifile can resolve all libraries, please run `arli bundle` inside the `src` folder. If Arli suceeds, you've got it right, and the `libraries` folder inside `src` should contain all referenced libraries.
@@ -30,12 +30,16 @@ module Arli
30
30
  raise Arli::Errors::LibraryNotFound,
31
31
  "Library #{cfg.to_hash} was not found" unless library
32
32
 
33
- self.arlifile = Arli::ArliFile.new(config: config, libraries: [ library ])
33
+ self.arlifile = Arli::ArliFile.new(config: config, libraries: [library])
34
34
  if config.trace
35
35
  info("found library using #{install_method}:\n#{library.inspect}")
36
36
  end
37
37
  end
38
38
 
39
+ def additional_info
40
+ "\nInstalling: #{runtime.argv.join(' ').bold.green}\n"
41
+ end
42
+
39
43
  def run
40
44
  arlifile.install
41
45
  end
@@ -44,14 +48,14 @@ module Arli
44
48
  def identify_library(arg)
45
49
  results = if arg =~ %r[https?://]i
46
50
  self.install_method = :url
47
- r = search(url: /^#{arg}$/i)
51
+ r = search(url: /^#{arg}$/i)
48
52
  if r.empty?
49
53
  self.install_method = :website
50
- r = search(website: /^#{arg}$/i)
54
+ r = search(website: /^#{arg}$/i)
51
55
  end
52
56
  if r.empty?
53
57
  self.install_method = :custom
54
- r = [ Arduino::Library::Model.from_hash(url: arg, name: File.basename(arg)) ]
58
+ r = [Arduino::Library::Model.from_hash(url: arg, name: File.basename(arg))]
55
59
  end
56
60
  r
57
61
  elsif File.exist?(arg) || arg =~ /\.zip$/
@@ -25,12 +25,16 @@ module Arli
25
25
 
26
26
  def initialize(*args)
27
27
  super(*args)
28
- self.format = config.search.results.output_format
28
+ self.format = config.search.results.output_format
29
29
  valid_methods = Arli::Library::MultiVersion.format_methods
30
30
  raise Arli::Errors::InvalidSearchSyntaxError,
31
31
  "invalid format #{format}" unless valid_methods.include?(format)
32
32
  end
33
33
 
34
+ def additional_info
35
+ "\nSearching For: #{runtime.argv.join(' ').bold.green}\n"
36
+ end
37
+
34
38
  def run
35
39
  self.search_opts = process_search_options!
36
40
  self.results = search(database, **search_opts).sort
@@ -112,7 +116,7 @@ module Arli
112
116
  def handle_and_raise_error(e)
113
117
  message = e.message
114
118
  if message =~ /undefined method.*Arduino::Library::Model/
115
- message = "Invalid attributed search. Possible values are:" +
119
+ message = 'Invalid attributed search. Possible values are:' +
116
120
  "\n#{Arduino::Library::Types::LIBRARY_PROPERTIES.keys}"
117
121
  end
118
122
  raise Arli::Errors::InvalidSearchSyntaxError,
@@ -121,10 +125,10 @@ module Arli
121
125
  end
122
126
 
123
127
  def print_total_with_help
124
- puts "———————————————————————"
128
+ hr_short
125
129
  puts " Total Versions : #{results.size.to_s.bold.magenta}\n"
126
130
  puts "Unique Libraries : #{unique_libraries.size.to_s.bold.magenta}\n"
127
- puts "———————————————————————"
131
+ hr_short
128
132
  if results.size == Arli::Configuration::DEFAULT_RESULTS_LIMIT
129
133
  puts "Hint: use #{'-m 5'.bold.green} to limit the result set."
130
134
  end
@@ -133,6 +137,11 @@ module Arli
133
137
  def params
134
138
  search_opts
135
139
  end
140
+
141
+ private
142
+ def hr_short
143
+ puts '———————————————————————'
144
+ end
136
145
  end
137
146
  end
138
147
  end
@@ -150,13 +150,13 @@ module Arli
150
150
  out << "\n#{command.params.to_s.blue}\n"
151
151
  end
152
152
  out << command.additional_info if command.respond_to?(:additional_info)
153
- out << "\nLibrary Path: #{Arli.default_library_path.green}\n"
154
- out << "#{hr}\n"
153
+ out << "Library Path: #{Arli.default_library_path.green}\n"
154
+ out << "#{hr}"
155
155
  info out
156
156
  end
157
157
 
158
158
  def hr
159
- ('-' * (ENV['COLUMNS'] || 80)).red.dark
159
+ ('' * ((ENV['COLUMNS'] || 70).to_i - 1)).red.dark
160
160
  end
161
161
 
162
162
  # Some shortcuts
@@ -20,7 +20,7 @@ module Arli
20
20
  end
21
21
 
22
22
  def install
23
- ___ "#{library.name.blue} "
23
+ ___ "#{library.name.blue.bold} "
24
24
  if library.nil? && library.library.nil?
25
25
  ___ ' (no library) '
26
26
  fuck
@@ -28,13 +28,13 @@ module Arli
28
28
  ___ ' (no url) '
29
29
  fuck
30
30
  else
31
- ___ "(#{library.version.green}) " if library.version
31
+ ___ "(#{library.version.yellow.bold}) " if library.version
32
32
  indent_cursor
33
33
  actions(library).each do |action|
34
34
  run_action(action)
35
35
  end
36
36
  end
37
- ___ "\n"
37
+ ___ "\n\n"
38
38
  end
39
39
 
40
40
  def run_action(action_name)
@@ -1,3 +1,3 @@
1
1
  module Arli
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Konstantin Gredeskoul
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-01-02 00:00:00.000000000 Z
11
+ date: 2018-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: arduino-library
@@ -234,11 +234,14 @@ dependencies:
234
234
  - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
- description: " This is an Arduino Library manager, compatible with the \"arduino-cmake\"
238
- project. \n Arli offers a powerful command-line tool to manage any number of dependent
239
- Github\n projects, or official Arduino libraries. Arli was created to offer Arduino-based
240
- \n projects of moderate to high complexity an easy way to reference external libraries\n
241
- \ and install them at build time, instead of committing them into the project repo.\n"
237
+ description: |2
238
+ This is an Arduino helper toolkit that builds on top of the arduino-cmake
239
+ project a powerful alternative build system for Arduino. What Arli provides
240
+ is capability to search for libraries by any attributes and regular expressions,
241
+ install a whole set of libraries defined in a YAML file Arlifile, and finally,
242
+ it can generate a brand new Sketch Project based on arduino-cmake, that builds
243
+ out the box. Arli is a command line tool, so run "arli" after installing the gem
244
+ for more information.
242
245
  email:
243
246
  - kigster@gmail.com
244
247
  executables:
@@ -329,9 +332,10 @@ rubyforge_project:
329
332
  rubygems_version: 2.6.13
330
333
  signing_key:
331
334
  specification_version: 4
332
- summary: This is an Arduino Library manager, compatible with the "arduino-cmake" project. Arli
333
- offers a powerful command-line tool to manage any number of dependent Github projects,
334
- or official Arduino libraries. Arli was created to offer Arduino-based projects
335
- of moderate to high complexity an easy way to reference external libraries and install
336
- them at build time, instead of committing them into the project repo.
335
+ summary: This is an Arduino helper toolkit that builds on top of the arduino-cmake
336
+ project a powerful alternative build system for Arduino. What Arli provides is
337
+ capability to search for libraries by any attributes and regular expressions, install
338
+ a whole set of libraries defined in a YAML file Arlifile, and finally, it can generate
339
+ a brand new Sketch Project based on arduino-cmake, that builds out the box. Arli
340
+ is a command line tool, so run "arli" after installing the gem for more information.
337
341
  test_files: []