piotrmurach / tty Goto Github PK
View Code? Open in Web Editor NEWToolkit for developing sleek command line apps.
Home Page: https://ttytoolkit.org
License: MIT License
Toolkit for developing sleek command line apps.
Home Page: https://ttytoolkit.org
License: MIT License
I see that @options
get passed for the command, but how do I get anything in there?
For example if I wanted to have following commands:
# using config-command to set value
app config foo=bar
# using config-command to read value
app config foo
# giving a flag for the command
app calculate_something --refresh-cache
Perhaps this is something that is documented somewhere, but I've missed that.
teletype new a-b
a-b/lib/a/b/cli.rb
a-b/lib/a-b/commands/.gitkeep
I assume this is not correct.
Running teletype new project will cause the following error to be emitted under ruby 2.5.1 on MacOS:
fatal: not a git repository (or any of the parent directories): .git
$ teletype new fubar
There is a call to Gem::Specification.load. This load invokes 'git ls-files' to expand the 'spec.files' value. Despite having a Dir.chdir in the generated spec code it is still in the wrong directory when this runs.
This is the code generated
# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
Putting a Dir.chdir in the calling code mitigates this issue.
( I couldn't get the gem package built properly so I will not put in a PR. Instead offer the following edit)
In lib\tty\commands\new.rb
def add_required_libs_to_gemspec
Dir.chdir target_path do
....
end
end
Hello!
Upon using the following line from the example listed in README.md, under section 1.2:
table.render :ascii, multiline: true
I am greeted with the following outpt:
The system cannot find the path specified.
The system cannot find the path specified.
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/tty-0.0.9/lib/tty/table/renderer/basic.rb:77:in `render': undefined method `border_class' for :ascii:Symbol (NoMethodError)
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/tty-0.0.9/lib/tty/support/delegatable.rb:38:in `render'
from C:/Users/psgs/Documents/GitHub/btcl/lib/btcl.rb:107:in `<top (required)>'
from -e:1:in `load'
from -e:1:in `<main>'
The table I am attempting to render is initialized at the top of the page using the following line of code:
table = TTY::Table.new(header: %w['Exchange', 'Price'])
Would anybody happen to know how to ensure that the table renders correctly?
Thankyou! ๐ด
#11 # Describe the problem
Overwrite executable warning
gem install tty-reader
# or
gem install tty-prompt
I get this warning in the terminal
wisper's executable "console" conflicts with countries
Overwrite the executable? [yN]
# for gem install tty-prompt
Fetching: necromancer-0.5.1.gem (100%)
Successfully installed necromancer-0.5.1
Fetching: equatable-0.6.1.gem (100%)
Successfully installed equatable-0.6.1
Fetching: tty-color-0.5.0.gem (100%)
Successfully installed tty-color-0.5.0
Fetching: pastel-0.7.3.gem (100%)
Successfully installed pastel-0.7.3
wisper's executable "console" conflicts with countries
Overwrite the executable? [yN] ERROR: Error installing tty-prompt:
"console" from wisper conflicts with installed executable from countries
I tried to find out what whisper even is and only found
https://rubygems.org/gems/whisper with no link to any viewable source code or documentation. So what does this even do?
Provide information of why I'm overwriting an executable, and what the dependency is even doing.
I tried to set up a simple yes/no question with a default of 'yes' and get an error when I simply press enter.
Running
TTY::Shell.new.ask 'So, yes or no ?' do
default 'yes'
end.read_bool
and pressing ENTER on the prompt leads to
[1] pry(main)> TTY::Shell.new.ask 'So, yes or no ?' do
[1] pry(main)* default 'yes'
[1] pry(main)* end.read_bool
So, yes or no ?
Necromancer::ConversionTypeError: '
' could not be converted from `string` into `boolean`
from /home/doudou/dev/flat_fish/.gems/gems/necromancer-0.3.0/lib/necromancer/converter.rb:48:in `fail_conversion_type'
(Note: the newline between the two quotes just after ConvertionTypeError is not a formatting glitch, it is displayed as-is on the terminal)
It seems that Question#evaluate_response expects 'nil' as 'no answer' but gets a newline character. Weirdly enough, if I do read_string, I get an empty string (no more newline)
teletype new does not work in the lates version (0.9.0)
teletype new app
9: from /usr/local/lib/ruby/gems/2.6.0/bin/teletype:23:in `load'
8: from /usr/local/lib/ruby/gems/2.6.0/gems/tty-0.9.0/exe/teletype:14:in `<top (required)>'
7: from /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
6: from /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
5: from /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
4: from /usr/local/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
3: from /usr/local/lib/ruby/gems/2.6.0/gems/tty-0.9.0/lib/tty/cli.rb:128:in `new'
2: from /usr/local/lib/ruby/gems/2.6.0/gems/tty-0.9.0/lib/tty/commands/new.rb:146:in `execute'
1: from /usr/local/lib/ruby/gems/2.6.0/gems/tty-0.9.0/lib/tty/commands/new.rb:234:in `add_required_libs_to_gemspec'
/usr/local/lib/ruby/gems/2.6.0/gems/tty-0.9.0/lib/tty/plugins.rb:58:in `load_from': undefined method `runtime_dependencies' for nil:NilClass (NoMethodError)
What happened? This could be a description, log output, error raised etc...
teletype should scaffold a new app
Not sure if it's properly an error on TTY once it happens on ruby-2.6.0dev, but requiring tty lib prints a git error out, even when -W0 flag is set it makes no difference:
Ruby version:
โ test ruby --version
ruby 2.6.0dev (2018-07-06 trunk 63870) [x86_64-linux]
Weird git message:
โ test ruby -W0 -e "require 'tty'; p 'ok'"
fatal: Not a git repository (or any of the parent directories): .git
"ok"
RVM version:
โ test rvm --version
rvm 1.29.4 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
Bundling a project with this gem and bundler 2 yields the following error:
Bundler could not find compatible versions for gem "bundler":
In Gemfile:
tty (~> 0.9.1) was resolved to 0.9.1, which depends on
bundler (< 2.0, ~> 1.16)
Current Bundler version:
bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?
Could not find gem 'bundler (< 2.0, ~> 1.16)', which is required by gem 'tty (~> 0.9.1)', in any of the sources.
This is because Bundler is pinned to <2.0 here.
source 'https://rubygems.org'
gem 'tty', '~> 0.9.1'
bundle
Display an incremental series of steps that get a checkmark and turn green when ok, or display an error symbol and turn red when not.
I have a particular use-case where I'm connecting to an LXD container via the REST api, and websockets, using a windows client - kitchen login
if you're familiar with that... much like vagrant - similar to an ssh connection, but more raw (no ssh client providing terminal emulation). The goal being an interactive session where you can inspect your container to see what is 'right' or 'wrong' in order to fine-tune your code and/or your tests. As such, it doesn't need to be 'fancy' or 'fully functional' but it does need to 'just work'.
The IO piping is stable, and I'm now in a place where I'm enabling the user to connect to the container and getting the visuals to render correctly.
On that note, I'm looking at writing a terminal emulator supporting either ANSI and/or VT100, and I wonder if you'd like that as an addition to your TTY ecosystem? It could be extended to support additional terminals in the future.
I've only kind of 'glanced' through the functions you currently provide, and I've already used a couple of your TTY gems to translate windows input and detect screen size. But, is there anything that I've overlooked that could do this rendering work for me?
Or if not, would you be adverse to including a 'tty-console' gem to your ecosystem? I've only just begun learning about console handling, but I'm assuming at this point (pending further research/testing) that a linux client would not need this special handling (that I could just directly pipe I/O from the container to the user's terminal in linux) so this 'might' be a windows specific deal.
where:
on http://piotrmurach.github.io/tty
place:
Alternatively, lookup your [favourite tty](http://piotrmurach.github.io/gems) gem and install it
what
missing link: http://piotrmurach.github.io/gems
The dependencies were updated recently (thanks!). Is there a new release being pushed to RubyGems anytime soon?
Looking forward to it!
It would be great if TTY supported running external commands. Example API below. Note that commands will be echoed if verbose is true.
attr_accessor :verbose
# run a command and echo output, raise an exception if it fails
def run(command, args = nil)
# run a command and return output, raise an exception if it fails
def run_capture(command, args = nil)
# run a command and suppress output, raise an exception if it fails
def run_quietly(command, args = nil)
# returns true if the command fails
def run_fails?(command, args = nil)
# returns true if the command succeeds
def run_succeeds?(command, args = nil)
It seems teletype isn't escaping / quoting the relative path (i.e. app name) for bundler, which then errors due to invalid arguments.
cd ~/
mkdir 'weird dir' && cd 'weird dir'
teletype new app
teletype new app
returns 1, prints traceback:
ERROR: "bundle gem" was called with arguments ["/Users/tim/weird", "dir/app"]
Usage: "bundle gem NAME [OPTIONS]"
Traceback (most recent call last):
9: from /Users/tim/.rbenv/versions/2.6.5/bin/teletype:23:in `<main>'
8: from /Users/tim/.rbenv/versions/2.6.5/bin/teletype:23:in `load'
7: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-0.10.0/exe/teletype:14:in `<top (required)>'
6: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
5: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
4: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
3: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
2: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
1: from /Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-0.10.0/lib/tty/commands/new.rb:126:in `execute'
/Users/tim/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/tty-command-0.9.0/lib/tty/command.rb:106:in `run': Running `bundle gem /Users/tim/weird dir/app --no-mit --no-exe --coc --no-ext -t rspec` failed with (TTY::Command::ExitError)
exit status: 15
stdout: ERROR: "bundle gem" was called with arguments ["/Users/tim/weird", "dir/app"]
Usage: "bundle gem NAME [OPTIONS]"
stderr: Nothing written
For the presence or absence of spaces in the project path to make no noticeable difference to an end-user's experience invoking teletype new
.
I only noticed this because I store some stuff in iCloud Drive, which has this unfortunate location on disk: /Users/tim/Library/Mobile Documents/com~apple~CloudDocs
.
When printing a table, the ANSI escape sequences factor into the column width detection, so columns with colored fields are significantly wider than they appear to need to be.
I tried patching the length function in TTY::Table::Field to strip color codes before length detection, which corrected the top borders. However, the rows including coloring still wouldn't pad correctly.
Is there some other way to do this? If not, I'll keep poking through for the function which pads the fields and submit a pull request if I fix it.
I'd like to add the following vim modeline to all .rb
files in tty-* gems:
# vim: expandtab ts=2 sw=2
It would be the first line in each file. This would help contributors who use vim greatly, especially if they are on the tab side of the space-tab wars - no more fighting with indentation.
I'd be willing to do pull requests for tty-* repos with these changes; I just wanted to bring it up here first and test the waters.
Semi-related:
I'd also like to argue the following: for a public code project, I believe tabs are a more 'friendly' option. I used to use spaces, myself (just look at my old code - wait... don't do that) - but my friend @mahlonsmith set me straight.
I believe this because most, if not all code editors allow customization of how tabs are displayed. Do you want a tab to be 2 spaces? 4? 150? Easy - in vim, set ts
and sw
. But if a project uses spaces, it's not easy to expand the 'tabs' if I need a bit more definition. Tabs enable readability when needed can be suited to any one programmer's sensibilities.
My :2cents: - I'd be happy with just the modeline :)
I created a new app with version from master. After running bin/setup
I tried to run following command and got an expection
./exe/project version
/Users/hasanen/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- ../project/cli (LoadError)
from /Users/hasanen/.rvm/rubies/ruby-2.4.2/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from ./exe/project:5:in `<main>'
On the file exe/project
in line 5 is following code:
require 'project/cli'
I changed it to following which solved the problem
require_relative '../lib/project/cli'
Is this correct way to fix this?
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/tty-0.10.0/lib/tty/commands/add.rb:69:in `read': No such file or directory @ rb_sysopen - li
b/rev2test/cli.rb (Errno::ENOENT)
Display progress on a single line and the ability to clean the current line when done. Typically this is stuff like percentage/bytes completed. Spinner would be nice.
Perhaps we can add file operations? TTY could add a lot of value. There are some subtleties here that go beyond what FileUtils provides.
For one thing, it can echo the commands if verbose is set to true. Note the if_necessary
variants - they only echo if the command is actually run. For example, mkdir_if_necessary("xyz") will only print "mkdir xyz" if that directory doesn't exist.
Also note that user and owner can be specified as strings instead of ids. etc.
Let me know if you are interested.
attr_accessor :verbose
def chmod(file, mode)
def chown(file, user)
def cp(src, dst, mkdir: false, owner: nil, mode: nil)
def ln(src, dst)
def mkdir(dir, owner: nil, mode: nil)
def mv(src, dst, mkdir: false)
def rm(file)
def rm_and_mkdir(dir)
def cp_if_necessary(src, dst, mkdir: false, owner: nil, mode: nil)
def ln_if_necessary(src, dst)
def mkdir_if_necessary(dir, owner: nil, mode: nil)
def rm_if_necessary(file)
In master, I build the gem and installed it
gem build tty.gemspec
gem install tty-0.7.0.gem
And then I tried to create new project
tmp โ teletype new test
Creating gem 'test'...
Code of conduct enabled in config
create test/Gemfile
create test/lib/test.rb
create test/lib/test/version.rb
create test/test.gemspec
create test/Rakefile
create test/README.md
create test/bin/console
create test/bin/setup
create test/.gitignore
create test/.travis.yml
create test/.rspec
create test/spec/spec_helper.rb
create test/spec/test_spec.rb
create test/CODE_OF_CONDUCT.md
append test/README.md
Invalid gemspec in [/Users/hasanen/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/tty.gemspec]: uninitialized constant TTY::VERSION
/Users/hasanen/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/lib/tty/plugins.rb:58:in `load_from': undefined method `runtime_dependencies' for nil:NilClass (NoMethodError)
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/lib/tty/commands/new.rb:222:in `add_required_libs_to_gemspec'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/lib/tty/commands/new.rb:138:in `execute'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/lib/tty/cli.rb:111:in `new'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/exe/teletype:13:in `<top (required)>'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/bin/teletype:23:in `load'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/bin/teletype:23:in `<main>'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `eval'
from /Users/hasanen/.rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks:15:in `<main>'
Using ruby 2.4.2. Let me know if you need more details.
[1] pry(main)> require 'rubygems'
true
[2] pry(main)> prompt = TTY::Prompt.new
NameError: uninitialized constant TTY
and in test.rb
require 'rubygems'
prompt = TTY::Prompt.new
prompt.ask('What is your name?', default: ENV['USER'
tty.rb:3:in `<main>': uninitialized constant TTY (NameError)
My setup:
[16] pry(main)> $:
[
[ 0] "/home/uminded/.rvm/gems/ruby-2.2.1@global/gems/executable-hooks-1.3.2/lib",
[ 1] "/home/uminded/.rvm/gems/ruby-2.2.1@global/extensions/x86_64-linux/2.2.0/executable-hooks-1.3.2",
[ 2] "/home/uminded/.rvm/gems/ruby-2.2.1@global/gems/bundler-unload-1.0.2/lib",
[ 3] "/home/uminded/.rvm/gems/ruby-2.2.1@global/gems/rubygems-bundler-1.4.4/lib",
[ 4] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/bundler-1.11.2/lib",
[ 5] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/io-console-0.4.5/lib",
[ 6] "/home/uminded/.rvm/gems/ruby-2.2.1/extensions/x86_64-linux/2.2.0/io-console-0.4.5",
[ 7] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/coderay-1.1.1/lib",
[ 8] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/slop-3.6.0/lib",
[ 9] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/method_source-0.8.2/lib",
[10] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/pry-0.10.3/lib",
[11] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/awesome_print-1.6.1/lib",
[12] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-color-0.3.0/lib",
[13] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-cursor-0.2.0/lib",
[14] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-screen-0.5.0/lib",
[15] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-which-0.1.0/lib",
[16] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/unicode_utils-1.4.0/lib",
[17] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/verse-0.4.0/lib",
[18] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-pager-0.4.0/lib",
[19] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-platform-0.1.0/lib",
[20] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-progressbar-0.8.1/lib",
[21] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/necromancer-0.3.0/lib",
[22] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/equatable-0.5.0/lib",
[23] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/pastel-0.6.0/lib",
[24] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/wisper-1.6.1/lib",
[25] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-prompt-0.4.0/lib",
[26] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-spinner-0.1.0/lib",
[27] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-table-0.5.0/lib",
[28] "/home/uminded/.rvm/gems/ruby-2.2.1/gems/tty-0.4.0/lib",
[29] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0",
[30] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/x86_64-linux",
[31] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby",
[32] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/vendor_ruby/2.2.0",
[33] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/vendor_ruby/2.2.0/x86_64-linux",
[34] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/vendor_ruby",
[35] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0",
[36] "/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/x86_64-linux"
]
In test.rb
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby/2.2.0/x86_64-linux
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/site_ruby
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/vendor_ruby/2.2.0
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/vendor_ruby/2.2.0/x86_64-linux
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/vendor_ruby
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0
/home/uminded/.rvm/rubies/ruby-2.2.1/lib/ruby/2.2.0/x86_64-linux
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.4.8
- RUBY VERSION: 2.2.1 (2015-02-26 patchlevel 85) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/uminded/.rvm/gems/ruby-2.2.1
- RUBY EXECUTABLE: /home/uminded/.rvm/rubies/ruby-2.2.1/bin/ruby
- EXECUTABLE DIRECTORY: /home/uminded/.rvm/gems/ruby-2.2.1/bin
- SPEC CACHE DIRECTORY: /home/uminded/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /home/uminded/.rvm/rubies/ruby-2.2.1/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/uminded/.rvm/gems/ruby-2.2.1
- /home/uminded/.rvm/gems/ruby-2.2.1@global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /home/uminded/.rvm/gems/ruby-2.2.1/bin
- /home/uminded/.rvm/gems/ruby-2.2.1@global/bin
- /home/uminded/.rvm/rubies/ruby-2.2.1/bin
- /usr/local/heroku/bin
- /usr/local/sbin
- /usr/local/bin
- /usr/sbin
- /usr/bin
- /sbin
- /bin
- /usr/games
- /usr/local/games
- /home/uminded/stlink
- /home/uminded/gcc-arm-none-eabi/bin
- /home/uminded/.rvm/bin
I ran gem install tty
to get the teletype
binary. It didn't work. I dug into it and found that the exe
dir is missing from the gem's installation dir.
I dug further and found that when you download the gem from rubygems.org, tty.gemspec
is different from what's here on GitHub. Notable differences:
spec.bindir
is missingspec.executables = spec.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
is used instead, which won't work since this project doesn't have a bin
dirAlso, the exe
dir is missing entirely when you download the gem from rubygems.org
So...did something go wrong in the gem cutting process that fouled-up tty.gemspec
?
I'm currently building a CLI with Teletype, which so far I'm loving - great work on the user experience of getting from zero to a decent CLI tool!
One thing that's not at all clear is how to make use of templates. Every command seems to generate a sub-directory in templates/
, which I presume is meant to have a bunch of Erb files dropped in it or something, but there's no documentation I can find on how to actually make use of those templates!
I noticed that unlike TTY::File.copy_directory(), TTY::File.copy_file() does't return a value on success.
Would be possible that both methods behave similar?
# Need of rescuing the method in order to know about the success
begin
TTY::File.copy_file( ... )
rescue
success = false
...
else
success = true
end
result = TTY::File.copy_file()
# result == nil in both error and success
Equivalent to its 'brother' method TTY::File.copy_directory()
Some terminals support hyperlinks. You can try following code in terminal:
printf '\e]8;;http://example.com\e\\This is a link\e]8;;\e\\\n'
In iTerm it prints underlined This is a link
and hovering it with cmd
key I'm able to click on it and browser opens http://example.com
link.
It would be nice to have a gem to:
Hello!
When I take a rows set with a single row like this:
rows = [['swag', 'derp', 'foo', 'bar']]
And render a new table with it, it works just swimmingly.
However, when I amend one of those with the syntax specified in the alignment section of the documentation...
rows = [['swag', 'derp', {:value => 'foo', :align => :right}, 'bar']]
...there is no change reflected in the table. The alignment of the selected cell does not change.
This remains true when attempting to align to the center, as well. Any help would be much appreciated.
Thanks!
In IRB, if I run this example from the documentation:
table = TTY::Table[['a1', 'a2'], ['b1', 'b2']]
I get:
NoMethodError: undefined method `header' for #<Object:0x007ffc110e1568>
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/tty-0.1.0/lib/tty/support/equatable.rb:90:in `block (2 levels) in define_compare'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/tty-0.1.0/lib/tty/support/equatable.rb:90:in `each'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/tty-0.1.0/lib/tty/support/equatable.rb:90:in `all?'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/tty-0.1.0/lib/tty/support/equatable.rb:90:in `block in define_compare'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/tty-0.1.0/lib/tty/support/equatable.rb:146:in `=='
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/awesome_print-1.2.0/lib/awesome_print/formatter.rb:66:in `awesome_self'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/awesome_print-1.2.0/lib/awesome_print/formatter.rb:28:in `format'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/awesome_print-1.2.0/lib/awesome_print/inspector.rb:137:in `unnested'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/awesome_print-1.2.0/lib/awesome_print/inspector.rb:104:in `awesome'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/kernel.rb:10:in `ai'
from /Users/gferguson/.rbenv/versions/2.1.3/lib/ruby/gems/2.1.0/gems/awesome_print-1.2.0/lib/awesome_print/core_ext/kernel.rb:20:in `ap'
from /Users/gferguson/.irbrc:33:in `output_value'
from /Users/gferguson/.rbenv/versions/2.1.3/bin/irb:11:in `<main>'
Hi there!
This looks like an awesome project. I'm installing 1.8.7 right now to see if your gem is compatible with it (I might be using it to create an install script).
The navigation on the website is a little troublesome. Some of the nav bar links scroll down, some are new pages. It'd be easier if it were all one kind of behavior. I almost didn't click on any after the first one, since it scrolled.
I gave follows when installed gem tty:
NOTE: Gem.gunzip is deprecated; use Gem::Util.gunzip instead. It will be removed on or after 2018-12-01.
Gem.gunzip called from /home/yart/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicode-display_width-1.1.3/lib/unicode/display_width/index.rb:5.
Sample of code:
require 'tty'
cursor = TTY::Cursor
cursor.invisible do
# some code
end
My environment
Steps
progressbar.rb:188:in `resize': Cannot resize finished progress bar (RuntimeError)
from /Users/aeufemio/.rvm/gems/ruby-2.3.0@digixdao/gems/tty-progressbar-0.8.1/lib/tty/progressbar.rb:309:in `block in register_signals'
from /Users/aeufemio/.rvm/gems/ruby-2.3.0@digixdao/gems/ethereum-0.4.95/lib/ethereum/transaction.rb:23:in `sleep'
from /Users/aeufemio/.rvm/gems/ruby-2.3.0@digixdao/gems/ethereum-0.4.95/lib/ethereum/transaction.rb:23:in `wait_for_miner'
from /Users/aeufemio/.rvm/gems/ruby-2.3.0@digixdao/gems/ethereum-0.4.95/lib/ethereum/contract.rb:205:in `block (3 levels) in build'
from bin/deploy:139:in `<main>'
Creating tables where you know the desired column widths (number of characters or percentages) but you don't know the number of rows yet, because you'd like to stream the rows, not wait for all the data until rendering.
I am building a CLI for work and wanted to try tty as I have heard great things about it.
As an FYI, I switched my Ruby environment to 2.7.2 and tried again and it worked just fine, so I'm guessing the issue is with the new Ruby version.
teletype new app
โฏ teletype new app
/Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-command-0.9.0/lib/tty/command.rb:54:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cmd.rb:33:in `new'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cmd.rb:33:in `command'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/commands/new.rb:46:in `initialize'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/exe/teletype:14:in `<top (required)>'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/bin/teletype:23:in `load'
from /Users/kowilson/.asdf/installs/ruby/3.0.0/bin/teletype:23:in `<main>'
I expected the gem to generate a new CLI app.
adding method_option :services, type: :boolean
causes tests (correctly) to fail:
1) `test-cmd config` command executes `test-cmd help config` command successfully
Failure/Error: expect(output).to eq(expected_output)
expected: "Usage:\n test-cmd config\n\nOptions:\n -h, [--help], [--no-help] # Display usage information\n\nCommand description...\n"
got: "Usage:\n test-cmd config\n\nOptions:\n -h, [--help], [--no-help] # Display usage information\n [--services], [--no-services] \n\nCommand description...\n"
and then when I copy/paste the output in
expected_output = <<-OUT
Usage:
test-cmd config
Options:
-h, [--help], [--no-help] # Display usage information
[--services], [--no-services]
Command description...
OUT
and I re-run the tests I get:
Failure/Error: expect(output).to eq(expected_output)
expected: "Usage:\n test-cmd config\n\nOptions:\n -h, [--help], [--no-help] # Display usage information\n [--services], [--no-services]\n\nCommand description...\n"
got: "Usage:\n test-cmd config\n\nOptions:\n -h, [--help], [--no-help] # Display usage information\n [--services], [--no-services] \n\nCommand description...\n"
And I'm giving up because this just feels stupid way to test and adjust whitespaces.
Another one - TTY could support csv reading & writing. Arrays of hashes/structs/ostructs can be written to csv, and reading a csv returns an array of structs.
def csv_read(path)
def csv_write(path, rows)
def csv_to_s(rows)
Let me know if you are interested.
Reposted from tty-file, by request.
Thanks, John for reporting!
Does the contacts command already exist when you're trying to create contacts phonelist subcommand? Would it be possible for you to report this issue at https://github.com/piotrmurach/tty since that's where the teletype tool is developed?
I cannot use teletype to create a subcommand of a command.
When I do I get an exception
> teletype add contacts phonelist --force 136ms
create spec/integration/contacts/phonelist_spec.rb
create spec/unit/contacts/phonelist_spec.rb
create lib/ddca/commands/contacts/phonelist.rb
create lib/ddca/templates/contacts/phonelist/.gitkeep
Traceback (most recent call last):
10: from /Users/jschank/.asdf/installs/ruby/2.5.1/bin/teletype:23:in `<main>'
9: from /Users/jschank/.asdf/installs/ruby/2.5.1/bin/teletype:23:in `load'
8: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/tty-0.8.1/exe/teletype:14:in `<top (required)>'
7: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/base.rb:466:in `start'
6: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
5: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
4: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
3: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/tty-0.8.1/lib/tty/cli.rb:88:in `add'
2: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/tty-0.8.1/lib/tty/commands/add.rb:131:in `execute'
1: from /Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/tty-file-0.6.0/lib/tty/file.rb:512:in `inject_into_file'
/Users/jschank/.asdf/installs/ruby/2.5.1/lib/ruby/gems/2.5.0/gems/tty-file-0.6.0/lib/tty/file.rb:512:in `escape': no implicit conversion of nil into String (TypeError)
It doesn't matter if I try to define parameters or not. I met this problem when I tried a more complex call:
> teletype add contacts phone_list --desc "Color code the phone extension list" --args contacts_file extension_xslx
Ultimately resulted in the same exception, from the same place
I use rvm on macos. After installing gem, command teletype
is not found. It seems that folder exe
is missing from the released version (not sure if that's related to the issue):
tmp โ la ~/.rvm/gems/ruby-2.4.2/gems/tty-0.7.0/
total 104
-rw-r--r-- 1 ext-hasanen 956722523 166B Oct 2 11:39 .gitignore
-rw-r--r-- 1 ext-hasanen 956722523 52B Oct 2 11:39 .rspec
-rw-r--r-- 1 ext-hasanen 956722523 366B Oct 2 11:39 .travis.yml
-rw-r--r-- 1 ext-hasanen 956722523 42B Oct 2 11:39 .yardopts
-rw-r--r-- 1 ext-hasanen 956722523 3.3K Oct 2 11:39 CHANGELOG.md
-rw-r--r-- 1 ext-hasanen 956722523 2.3K Oct 2 11:39 CODE_OF_CONDUCT.md
-rw-r--r-- 1 ext-hasanen 956722523 359B Oct 2 11:39 Gemfile
-rw-r--r-- 1 ext-hasanen 956722523 1.0K Oct 2 11:39 LICENSE.txt
-rw-r--r-- 1 ext-hasanen 956722523 7.3K Oct 2 11:39 README.md
-rw-r--r-- 1 ext-hasanen 956722523 141B Oct 2 11:39 Rakefile
-rw-r--r-- 1 ext-hasanen 956722523 482B Oct 2 11:39 appveyor.yml
drwxr-xr-x 3 ext-hasanen 956722523 102B Oct 2 11:39 images
drwxr-xr-x 4 ext-hasanen 956722523 136B Oct 2 11:39 lib
drwxr-xr-x 5 ext-hasanen 956722523 170B Oct 2 11:39 spec
drwxr-xr-x 6 ext-hasanen 956722523 204B Oct 2 11:39 tasks
-rw-r--r-- 1 ext-hasanen 956722523 1.7K Oct 2 11:39 tty.gemspec
ruby: 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
tty: 0.6.0
tty-which: 0.2.1
OS: Linux (Arch)
With 0.5.0, I could use TTY::Which
by requiring tty
e.g.:
require 'tty'
TTY::Which.which 'ruby' # => "/usr/bin/ruby"
That no longer works in 0.6.0. It appears that unqualified references to File
in TTY::Which
are now being resolved to TTY::File
rather than ::File
.
I can work around this by requiring tty-which
directly, but this was an unexpected (breaking) change, and I can't see any mention of it in the changelog.
(This might affect other tty-
modules. Some of them have qualified ::File
references, some unqualified, and some (e.g. tty-color
) have a mixture of the two.)
gem 'tty', '= 0.5.0'
require 'tty'
puts TTY::Which.which('ruby')
$ ruby test-0.5.0.rb
/usr/bin/ruby
gem 'tty', '= 0.6.0'
require 'tty'
puts TTY::Which.which('ruby')
$ ruby test-0.6.0.rb
~/.gem/ruby/2.4.0/gems/tty-which-0.2.1/lib/tty/which.rb:157:in `file_with_path?': undefined method `expand_path' for TTY::File:Module (NoMethodError)
from ~/.gem/ruby/2.4.0/gems/tty-which-0.2.1/lib/tty/which.rb:23:in `which'
from test-0.6.0.rb:3:in `<main>'
Hello Peter,
First of all, thank you for creating this very nice gem, I really like how it will be this ultimate Terminal gem.
I'm making a console application, and I want to detect a keypress (more specifically, arrow keys). What I want is that when the user presses an arrow key, that something happens.
So I was trying things out, but they don't work as I expected. I tried the following code:
require "tty"
shell = TTY::Shell.new
p shell.ask("").echo(false).read_char
I expected it to return after I type a single character, but it waited for me to press "Enter". I also expected that the input won't be displayed at any point, but it was displayed after I pressed "Enter". Concretely, when I typed foo<Enter>
, I got the following output:
foo"f"
So, my input has been displayed + the first character inspected. I'm aware that detecting arrow keys will probably be a bit trickier, because they're two characters (e.g. ^[[B
), but I first have to figure out how to read letters without "Enter" needing to be pressed.
I saw on StackOverflow that the raw
setting needs to be enabled for "character input":
system "stty raw"
# do some work
system "stty -raw"
$ teletype new test-cmd
# remove todos from gemspec
$ teletype add config
$ rake
1) `test-cmd config` command executes `test-cmd help config` command successfully
Failure/Error: output = `test-cmd help config`
Errno::ENOENT:
No such file or directory - test-cmd
"fix" by prefixing runner to use exe/test-cmd
:
RSpec.describe "`test-cmd config` command", type: :cli do
it "executes `test-cmd help config` command successfully" do
output = `exe/test-cmd help config`
Specs fail on ruby 2.7.0p0, mostly due to deprecation of hash argument being treated as keywords by ruby < 2.7.0 but deprecated in 2.7.0+.
bundle exec rake spec
using ruby 2.7.0p0
Finished in 10.59 seconds (files took 0.39076 seconds to load)
42 examples, 20 failures, 1 pending
Failed examples:
rspec ./spec/integration/new_spec.rb:271 # teletype new generates C extensions boilerplate
rspec ./spec/integration/new_spec.rb:292 # teletype new generates code of conduct file
rspec ./spec/integration/new_spec.rb:321 # teletype new displays help
rspec ./spec/integration/new_spec.rb:5 # teletype new generates cli application
rspec ./spec/integration/new_namespaced_spec.rb:2 # teletype new generates cli application namespaced
rspec ./spec/integration/add_force_spec.rb:2 # `teletype add --force` command forces adding already existing command
rspec ./spec/integration/add_subcommand_spec.rb:2 # `teletype add` subcommad adds a new subcommand
rspec ./spec/integration/add_subcommand_spec.rb:175 # `teletype add` subcommad adds a new subcommand with minitest
rspec ./spec/integration/add_spec.rb:238 # `teletype add` command adds more than one command to cli file
rspec ./spec/integration/add_spec.rb:2 # `teletype add` command adds a command
rspec ./spec/integration/add_spec.rb:343 # `teletype add` command adds complex command name as camel case
rspec ./spec/integration/add_spec.rb:415 # `teletype add` command adds complex command name as snake case
rspec ./spec/integration/add_spec.rb:122 # `teletype add` command adds a command with minitests
rspec ./spec/integration/add_spec.rb:498 # `teletype add` command displays help
rspec ./spec/integration/add_spec.rb:186 # `teletype add` command adds command in cli without any commands
rspec ./spec/integration/add_namespaced_spec.rb:127 # teletype add adds a subcommand to namespaced application
rspec ./spec/integration/add_namespaced_spec.rb:2 # teletype add adds a command to namespaced application
rspec ./spec/integration/add_desc_args_spec.rb:124 # `teletype add --desc --args` command adds command with variadic number of arguments
rspec ./spec/integration/add_desc_args_spec.rb:250 # `teletype add --desc --args` command adds subcommand with description and custom arguments
rspec ./spec/integration/add_desc_args_spec.rb:4 # `teletype add --desc --args` command adds command with description and custom arguments
Specs to pass
Last one, I promise. Here are a few more common helpers that we tend to use in scripts:
# Who is the current user?
def whoami
# Return true if the current user is "root".
def root?
# Return the md5 checksum for the file at +path+.
def md5_file(path)
# Return the md5 checksum for +str+.
def md5_string(str)
# Return a random alphanumeric string of length +len+.
def random_string(len)
I'd be happy to add these too! I might need some guidance on where to place them.
I have a simple script as part of a gem... the prompt, commands are working fine but rendering the tables doesn't work at all...
TTY::Command.new(printer: :quiet).run('clear')
TTY::Prompt.new.say("Updated at: #{Time.now}")
table = TTY::Table.new ['header1','header2'], [['a1', 'a2'], ['b1', 'b2']]
table.render :ascii
this doesn't output only the table to the terminal... but puts table.to_s
outputs the following
"+-------+-------+\n|header1|header2|\n+-------+-------+\n|a1 |a2 |\n|b1 |b2 |\n+-------+-------+"
macOS Sierra (10.12.1)
ruby 2.3.2
Perhaps more of a feature suggestion than a problem :) I noticed that when making a new app with teletype
, it adds all of the 'tty' gems as dependencies, even though (by default) none of them are used or require
d:
spec.add_dependency "tty-box", "~> 0.4.1"
spec.add_dependency "tty-color", "~> 0.5"
spec.add_dependency "tty-command", "~> 0.9.0"
spec.add_dependency "tty-config", "~> 0.3.2"
spec.add_dependency "tty-cursor", "~> 0.7"
spec.add_dependency "tty-editor", "~> 0.5"
spec.add_dependency "tty-file", "~> 0.8.0"
spec.add_dependency "tty-font", "~> 0.4.0"
spec.add_dependency "tty-logger", "~> 0.2.0"
spec.add_dependency "tty-markdown", "~> 0.6.0"
spec.add_dependency "tty-pager", "~> 0.12"
spec.add_dependency "tty-pie", "~> 0.3.0"
spec.add_dependency "tty-platform", "~> 0.2"
spec.add_dependency "tty-progressbar", "~> 0.17"
spec.add_dependency "tty-prompt", "~> 0.19"
spec.add_dependency "tty-screen", "~> 0.7"
spec.add_dependency "tty-spinner", "~> 0.9"
spec.add_dependency "tty-table", "~> 0.11.0"
spec.add_dependency "tty-tree", "~> 0.3"
spec.add_dependency "tty-which", "~> 0.4"
This seems inefficient; if I install this gem straight out of the box - no commands added, etc - I'd get 20 other gems along with it, even though none of them are used (seemingly).
teletype new test-app
grep 'dependency' test-app/test-app.gemspec
My initial thoughts were:
a) use the 'teletype' command to add a new component. for example, teletype require prompt
(???)
b) when running rake build
, scrape any require
s that reference a tty gem
Option "b" sounds more automated (yay!) but hacky (boo!). Option "a" feels clunky (i.e. why would i need to run teletype
instead of just adding a require 'tty/prompt'
line..?)... so I'm not sure either suggestion is the best. Opening this more for discussion than anything!
Creating a new app fails
teletype new app
/Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-command-0.9.0/lib/tty/command.rb:54:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cmd.rb:33:in `new'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cmd.rb:33:in `command'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/commands/new.rb:46:in `initialize'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/lib/tty/cli.rb:128:in `new'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/thor-0.20.3/lib/thor/base.rb:466:in `start'
from /Users/roeland/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/tty-0.10.0/exe/teletype:14:in `<top (required)>'
from /Users/roeland/.rbenv/versions/3.0.0/bin/teletype:23:in `load'
from /Users/roeland/.rbenv/versions/3.0.0/bin/teletype:23:in `<main>'
shouldn't fail
A brief description of the issue/feature.
teletype new test-app
cd test-app
teletype help
When using any teletype
command, you get a series of exceptions related to metadata:
[katelyn@h test-app]$ teletype help
Traceback (most recent call last):
6: from /home/katelyn/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:10:in `<main>'
5: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `run'
4: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `each'
3: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:50:in `block in run'
2: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems_executable_plugin.rb:4:in `block in <top (required)>'
1: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- rubygems-bundler/noexec (LoadError)
33: from /home/katelyn/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:10:in `<main>'
32: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `run'
31: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `each'
30: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:50:in `block in run'
29: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems_executable_plugin.rb:4:in `block in <top (required)>'
28: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
27: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
26: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
25: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:131:in `<top (required)>'
24: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:124:in `check'
23: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:92:in `setup'
22: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:51:in `candidate?'
21: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:203:in `missing_specs'
20: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:247:in `resolve'
19: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:744:in `converge_locked_specs'
18: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:744:in `each'
17: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:758:in `block in converge_locked_specs'
16: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:108:in `specs'
15: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:100:in `local_specs'
14: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:165:in `load_spec_files'
13: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:165:in `each'
12: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:171:in `block in load_spec_files'
11: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:157:in `validate_spec'
10: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:61:in `validate'
9: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/ui/silent.rb:61:in `silence'
8: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:61:in `block in validate'
7: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:2654:in `validate'
6: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:64:in `validate'
5: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:95:in `validate_metadata'
4: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:95:in `each'
3: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:114:in `block in validate_metadata'
2: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification_policy.rb:399:in `error'
1: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/delegate.rb:85:in `method_missing'
/home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/2.6.0/delegate.rb:85:in `call': metadata['homepage_uri'] has invalid link: "TODO: Put your gem's website or public repo URL here." (Gem::InvalidSpecificationException)
24: from /home/katelyn/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:10:in `<main>'
23: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `run'
22: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:49:in `each'
21: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/executable-hooks-1.6.0/lib/executable-hooks/hooks.rb:50:in `block in run'
20: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems_executable_plugin.rb:4:in `block in <top (required)>'
19: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
18: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `rescue in require'
17: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:130:in `require'
16: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:131:in `<top (required)>'
15: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:124:in `check'
14: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:92:in `setup'
13: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/rubygems-bundler-1.4.5/lib/rubygems-bundler/noexec.rb:51:in `candidate?'
12: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:203:in `missing_specs'
11: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:247:in `resolve'
10: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:744:in `converge_locked_specs'
9: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:744:in `each'
8: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/definition.rb:758:in `block in converge_locked_specs'
7: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:108:in `specs'
6: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:100:in `local_specs'
5: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:165:in `load_spec_files'
4: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:165:in `each'
3: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:171:in `block in load_spec_files'
2: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/source/path.rb:157:in `validate_spec'
1: from /home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:60:in `validate'
/home/katelyn/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/bundler/rubygems_integration.rb:65:in `rescue in validate': The gemspec at /home/katelyn/code/test-app/test-app.gemspec is not valid. Please fix this gemspec. (Gem::InvalidSpecificationException)
The validation error was 'metadata['homepage_uri'] has invalid link: "TODO: Put your gem's website or public repo URL here."'
Other errors I ran into while stepping through the errors:
The validation error was '"FIXME" or "TODO" is not a description'
The validation error was 'metadata['source_code_uri'] has invalid link: "TODO: Put your gem's public repo URL here."'
The validation error was 'metadata['changelog_uri'] has invalid link: "TODO: Put your gem's CHANGELOG.md URL here."'
The validation error was '"TODO: Put your gem's website or public repo URL here." is not a valid HTTP URI'
I'd expect either a pretty message ("First, modify test-app.gemspec!"), or for the "TODO:" lines to be commented out. The issue was solved by commenting out the 'uri' metadata(s), and modifying the summary/description... but it wasn't immediately obvious (especially since I missed the 'validation error' and went straight to 'wait, what's wrong with rubygems-bundler/noexec?').
I think it could be fixed globally by changing the default spec like this:
- spec.summary = %q{TODO: Write a short summary, because RubyGems requires one.}
- spec.description = %q{TODO: Write a longer description or delete this line.}
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
+ spec.summary = %q{My new teletype app.}
+ spec.description = %q{My new teletype app.}
+ #spec.homepage = "TODO: Put your gem's website or public repo URL here."
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
+ #spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
- spec.metadata["homepage_uri"] = spec.homepage
- spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
- spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
+ spec.metadata["homepage_uri"] = spec.homepage if spec.homepage
+ #spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
+ #spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
Alternatively, if the validations are coming from tty
itself, maybe just printing a 'update your gemspec first!' message would be enough. Unsure what would be the best approach.
tty (0.10.0)
tty-box (0.4.1)
tty-color (0.5.2)
tty-command (0.9.0)
tty-config (0.3.2)
tty-cursor (0.7.1)
tty-editor (0.5.1)
tty-file (0.8.0)
tty-font (0.4.0)
tty-logger (0.2.0)
tty-markdown (0.6.0)
tty-pager (0.13.0)
tty-pie (0.3.0)
tty-platform (0.3.0)
tty-progressbar (0.17.0)
tty-prompt (0.22.0, 0.21.0)
tty-reader (0.8.0, 0.7.0)
tty-screen (0.8.0)
tty-spinner (0.9.3)
tty-table (0.11.0)
tty-tree (0.4.0)
tty-which (0.4.2)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.