Merge lp:~ted/ubuntu-app-launch/app-info-tool into lp:ubuntu-app-launch/16.04

Proposed by Ted Gould on 2016-04-29
Status: Merged
Approved by: Charles Kerr on 2016-05-04
Approved revision: 222
Merged at revision: 220
Proposed branch: lp:~ted/ubuntu-app-launch/app-info-tool
Merge into: lp:ubuntu-app-launch/16.04
Diff against target: 97 lines (+82/-0)
2 files modified
tools/CMakeLists.txt (+9/-0)
tools/ubuntu-app-info.cpp (+73/-0)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/app-info-tool
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve on 2016-05-04
Larry Price 2016-04-29 Approve on 2016-05-04
PS Jenkins bot (community) continuous-integration Needs Fixing on 2016-05-04
Review via email: mp+293457@code.launchpad.net

Commit message

Add a small commandline tool for application information

To post a comment you must log in.
221. By Ted Gould on 2016-04-29

Add some exception handling for better output

Larry Price (larryprice) wrote :

Should we have consistency in checking the contents of argv[1] for empty with the other tool?

review: Needs Information
Charles Kerr (charlesk) wrote :

Looks like a useful tool to have.

A crasher + a couple of minor comments inline

review: Needs Fixing
Ted Gould (ted) :
Charles Kerr (charlesk) wrote :

huh, TIL. I retract my previous NF. :)

222. By Ted Gould on 2016-05-04

Check for empty appid and null app

Larry Price (larryprice) wrote :

lgtm

review: Approve
Charles Kerr (charlesk) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/CMakeLists.txt'
2--- tools/CMakeLists.txt 2016-02-08 19:03:31 +0000
3+++ tools/CMakeLists.txt 2016-05-04 14:09:31 +0000
4@@ -18,6 +18,15 @@
5 install(TARGETS ubuntu-app-list-pids RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
6
7 ########################
8+# ubuntu-app-info
9+########################
10+
11+add_executable(ubuntu-app-info ubuntu-app-info.cpp)
12+set_target_properties(ubuntu-app-info PROPERTIES OUTPUT_NAME "ubuntu-app-info")
13+target_link_libraries(ubuntu-app-info ubuntu-launcher)
14+install(TARGETS ubuntu-app-info RUNTIME DESTINATION "${CMAKE_INSTALL_FULL_BINDIR}")
15+
16+########################
17 # ubuntu-app-launch
18 ########################
19
20
21=== added file 'tools/ubuntu-app-info.cpp'
22--- tools/ubuntu-app-info.cpp 1970-01-01 00:00:00 +0000
23+++ tools/ubuntu-app-info.cpp 2016-05-04 14:09:31 +0000
24@@ -0,0 +1,73 @@
25+/*
26+ * Copyright 2016 Canonical Ltd.
27+ *
28+ * This program is free software: you can redistribute it and/or modify it
29+ * under the terms of the GNU General Public License version 3, as published
30+ * by the Free Software Foundation.
31+ *
32+ * This program is distributed in the hope that it will be useful, but
33+ * WITHOUT ANY WARRANTY; without even the implied warranties of
34+ * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
35+ * PURPOSE. See the GNU General Public License for more details.
36+ *
37+ * You should have received a copy of the GNU General Public License along
38+ * with this program. If not, see <http://www.gnu.org/licenses/>.
39+ *
40+ * Authors:
41+ * Ted Gould <ted.gould@canonical.com>
42+ */
43+
44+#include <iostream>
45+#include "libubuntu-app-launch/application.h"
46+#include "libubuntu-app-launch/registry.h"
47+
48+int main(int argc, char* argv[])
49+{
50+ if (argc != 2) {
51+ std::cerr << "Usage: " << argv[0] << " (appid)" << std::endl;
52+ exit(1);
53+ }
54+
55+ auto appid = ubuntu::app_launch::AppID::find(argv[1]);
56+ if (appid.empty()) {
57+ std::cerr << "Unable to find app for appid: " << argv[1] << std::endl;
58+ return 1;
59+ }
60+
61+ std::shared_ptr<ubuntu::app_launch::Application> app;
62+ try {
63+ app = ubuntu::app_launch::Application::create(appid, ubuntu::app_launch::Registry::getDefault());
64+ if (!app)
65+ throw std::runtime_error("Application object is nullptr");
66+ } catch (std::runtime_error &e) {
67+ std::cerr << "Unable to find application for AppID: " << argv[1] << std::endl;
68+ exit(1);
69+ }
70+
71+ try {
72+ auto info = app->info();
73+
74+ std::cout << "Name: " << info->name().value() << std::endl;
75+ std::cout << "Description: " << info->description().value() << std::endl;
76+ std::cout << "Icon Path: " << info->iconPath().value() << std::endl;
77+ std::cout << "Splash: " << std::endl;
78+ std::cout << " Title: " << info->splash().title.value() << std::endl;
79+ std::cout << " Image: " << info->splash().image.value() << std::endl;
80+ std::cout << " BG Color: " << info->splash().backgroundColor.value() << std::endl;
81+ std::cout << " Header Color: " << info->splash().headerColor.value() << std::endl;
82+ std::cout << " Footer Color: " << info->splash().footerColor.value() << std::endl;
83+ std::cout << " Show Header: " << info->splash().showHeader.value() << std::endl;
84+ std::cout << "Orientations: " << std::endl;
85+ std::cout << " Portrait: " << info->supportedOrientations().portrait << std::endl;
86+ std::cout << " Landscape: " << info->supportedOrientations().landscape << std::endl;
87+ std::cout << " Inv Portrait: " << info->supportedOrientations().invertedPortrait << std::endl;
88+ std::cout << " Inv Landscape: " << info->supportedOrientations().invertedLandscape << std::endl;
89+ std::cout << "Rotates: " << info->rotatesWindowContents().value() << std::endl;
90+ std::cout << "Ubuntu Lifecycle: " << info->supportsUbuntuLifecycle().value() << std::endl;
91+ } catch (std::runtime_error &e) {
92+ std::cerr << "Unable to parse Application info for application '" << std::string(appid) << "': " << e.what() << std::endl;
93+ exit(1);
94+ }
95+
96+ return 0;
97+}

Subscribers

People subscribed via source and target branches