Skip to content

Commit f73e99b

Browse files
committed
Using Thor for CLI and minor documentation changes
1 parent f5a5d71 commit f73e99b

File tree

3 files changed

+39
-8
lines changed

3 files changed

+39
-8
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Installs OS-specific packages required to run your gems.
44

5+
Inspired by [Natives](https://github.com/teohm/natives) gem by @teohm.
6+
7+
Native anonymously communicates with a remote server to determine the required
8+
native dependencies for your gems. No data is sent or collected without your
9+
approval.
10+
511
## Installation
612

713
Add this line to your application's Gemfile:
@@ -20,7 +26,9 @@ Or install it yourself as:
2026

2127
## Usage
2228

23-
Run `native` before `bundle install`.
29+
Before running `bundle install`, Run:
30+
31+
$ native
2432

2533
## Development
2634

bin/native

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
#!/usr/bin/env ruby
22

3-
require 'bundler/setup'
4-
require 'native'
3+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
54

6-
file = 'Gemfile.lock'
7-
lockfile = Bundler::LockfileParser.new(Bundler.read_file(file))
8-
platform = Native::Platform.new
9-
puts "Detected OS: #{platform.name} #{platform.version}"
10-
puts lockfile.specs.map(&:name)
5+
require 'native/cli'
6+
7+
Native::Cli.start

lib/native/cli.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require 'thor'
2+
require 'native'
3+
require 'bundler'
4+
5+
module Native
6+
# Command Line Interface
7+
class Cli < Thor
8+
desc 'list', 'list native packages required by the catalog entries'
9+
method_option :file, default: 'Gemfile.lock', desc: 'dependency file'
10+
def list(file)
11+
lockfile = ::Bundler::LockfileParser.new(Bundler.read_file(file))
12+
puts lockfile.specs.map(&:name)
13+
end
14+
15+
desc 'detect', 'detect and print platform and package provider information'
16+
def detect
17+
platform = Native::Platform.new
18+
puts "Detected OS: #{platform.inspect} #{platform.version}"
19+
end
20+
21+
desc 'version', 'print version information'
22+
def version
23+
puts "Native version #{VERSION}"
24+
end
25+
end
26+
end

0 commit comments

Comments
 (0)