Last Updated
Viewed 28 Times

I'm trying to get my more_info method to work when a user types something other than y, n, or exit. When the "Invalid entry" message pops up, and then the user types y, a random restaurant will show up instead of the complete list of restaurants.

class CLI
    def begin
        OpenDataAPI.get_data
        puts "Welcome to the Restaurant Inspection CLI!"
        menu
    end

    def menu
        input = nil
          puts "Type 1 for a list of Restaurants, type Exit to exit the program at anytime."
          while input != "exit"
          input = gets.strip.downcase
          if input == "1"
            RestaurantInspections.all.each.with_index do |restaurant, index|
              puts "#{index + 1}: #{restaurant.restaurant_name}"
            end
            more_info
          elsif input == "exit"
            exit
        else
            puts "Invalid entry, please type either 1 or exit."
        end
    end
    end

    def more_info
        input = nil
        puts "\nPlease type the number of the restaurant you'd like to learn more about."
        while input != "exit"
        input = gets.to_i
        restaurant = RestaurantInspections.all[input.to_i - 1]
        OpenDataAPI.single_data(restaurant)
        puts "\nRestaurant Name: #{restaurant.restaurant_name}"
        puts "Type of Food: #{restaurant.type_of_food}"
        puts "Grade Rating: #{restaurant.grade}"
        puts "Violation Description: #{restaurant.violation_description}"
        puts "\nWould you like to see a different restaurant? (y/n)"
        input = gets.strip.downcase
          if input == "y"
            RestaurantInspections.all.each.with_index do |restaurant, index|
              puts "#{index + 1}: #{restaurant.restaurant_name}"
            end
        elsif input == "exit"
            exit
        elsif input ==  "n"
            puts "\nThanks for using the Restaurant Data CLI!"
            puts "\n"
            exit
        else
            puts "Invalid entry, please type y, n, or exit."
          end
      end
      end
end

How can I fix this so the list of restaurants shows up instead?

I am trying to list all the subscriptions of a logged in user. Something that $ az account list provides. I am looking for REST API equivalent or Java SDK equivalent.

What am I missing here?

Every time I use the URL https://management.azure.com/subscriptions?api-version=2019-06-01 It returns only 1 subscription.

expecting something like following

[

  {
    "cloudName": "AzureCloud",
    "id": "87654321-de26-zzzz-b714-184nd94h1000",
    "isDefault": true,
    "name": "Test2",
    "state": "Enabled",
    "tenantId": "12345678-3333-4444-8787-000000111111",
    "user": {
      "name": "foo@hotmail.com",
      "type": "user"
    }
  },
  {
    "cloudName": "AzureCloud",
    "id": "12345678-4321-1234-4444-111111000000",
    "isDefault": false,
    "name": "Test1",
    "state": "Enabled",
    "tenantId": "88888888-4444-3333-1111-010101010101",
    "user": {
      "name": "foo@hotmail.com",
      "type": "user"
    }
  }
]

and run perform something equivalent of following commands. Of course inlot more details.

$ az account set -s 87654321-de26-zzzz-b714-184nd94h1000
$ az vm list
$ az account set -s 12345678-4321-1234-4444-111111000000
$ az vm list

I am using service principal and other Tenant invited the user as guest user.

One of the main requirement is not using browser based initial login since this application will work as a daemon.

I'm trying to create a resume based on the details of a person that I have in my database. I have access to his basic details, education, work experience,... with me.

There is a GitHub repo called [hackmyresume] (https://github.com/hacksalot/HackMyResume) that creates polished résumés and CVs in multiple formats from your command line or shell. It takes input in JSON format(Fresh Schema) and converts that to Word, HTML, PDF, LaTeX, plain text, and other arbitrary formats.

hackmyresume build resume.json TO out/resume.all -t

Everything works as expected if I follow the instructions in the readme page of the repo. But I would like to replicate this functionality in node API. Please guide me.

I'm trying to find how is the best way to make a cross platform CLI, that's working everywhere: Windows, Mac, iOS, Android and Linux.

I started a thing in C, but building the libraries for each platform is horrible work and very complicated, just tried to build sqlite for windows, I think I'm not going the right way.

So is there a "thing" that can provide fast performance and easy cross-platform building, a thing such as Qt maybe?

Or it is simpler to re code everything for each platform?

I thought it was easier to build cross-platform C code when there's no GUI involved but couldn't find anything.

Tried cmake, but it's very complicated to understand for anyone who always used make and I don't think it's easy to use under iOS or Android.

Maybe there is a Package manager that's working everywhere? were I can install sqlite easily on every platform.

I want to build an API that's working everywhere so a GUI can use it, the GUI that I want to code platform specific.

Similar Question 4 (2 solutions) : How to escape strings for terminal in Ruby?

Similar Question 6 (1 solutions) : How to set Commander gem default command?

Similar Question 7 (1 solutions) : how to get options passed before ruby executable?

Similar Question 9 (4 solutions) : How do I run Rake tasks within a Ruby script?

cc