Code Monkey home page Code Monkey logo

pn's Introduction

pn -- a libphonenumber command-line wrapper, and GNU AWK extension

pn is a tool that allows command line user/programmers to operate on phone numbers (get validity information, reformat them, or extract numbers from a text snippet), using libphonenumber.

This repository also contains a GNU AWK extension library, exposing some libphonenumber features in AWK. See gawkext/README.md for more details.

Features

See the man page for more details.

Check the validity of a number:

$ pn valid -v +33123456789
valid number
(SUCCESS)
$ pn valid -v '(202) 555-0110'
invalid country code
(ERROR)
$ pn valid -v -c US '(202) 555-0110'
valid number
(SUCCESS)

Re-format a phone number:

$ pn format "+1 20 2 555    01 10"
+12025550110
$ pn format -c FR "0123456789"
+33123456789
$ pn format -c FR -f nat "0123456789"
01 23 45 67 89
$ pn format -f int "+12025550110"
+1 202-555-0110

Find valid numbers inside a free text input:

$ pn find -f nat "2017/04/20: You have 2 messsages, call +1-202-555-0110 to listen to them."
(202) 555-0110
$ pn find -c FR "rappelle-moi au 01 23 4 56789 ou au 06 78 90 12 34 après 20h00"
+33123456789
+33678901234

Get some informations about a number:

$ pn info "+33 2 96 48 46 98"
country code: 33 (FR)
number type: fixed line
location: Lannion
possible short number: false
valid short number: false
emergency number: false

$ pn info -c FR 112
country code: 33 (FR)
number type: unknown
location: 
possible short number: true
valid short number: true
emergency number: true

How to build pn?

Prerequisites

For Debian (>= 9), Ubuntu (>= 16.10):

$ sudo apt install cmake build-essential libphonenumber-dev libicu-dev

For Ubuntu 16.04:

$ sudo apt install cmake build-essential libphonenumber-dev libgeocoding-dev libicu-dev

Note: You might want to use a newer version of libphonenumber than the one packaged by your distribution. In that case, fetch the source code and compile it on your own, following the instructions provided here.

Other platforms:

To build pn you need a C++ compiler, CMake, Google's libphonenumber (including the geocoding part) binaries and dev headers, ICU binaries and dev headers.

Build

Provided that the prerequisites are met, to build pn and the gawk extension gawkpn.so (it is only compiled if CMake was able to locaite gawk's .h header on the system) simply issue :

pn/$ cd build
pn/build/$ cmake ..
pn/build/$ make

Install

pn/build/$ sudo make install

pn's People

Contributors

camilleoudot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pn's Issues

Standard C++ 11 flag

Depending on your system, it may happen that cmake will not use the standard C++11 version causing many errors when compiling pn.cc (such as: 'char16_t' does not name a type).
Adding the "-std=gnu++11" flag to 'build/CMakeCache.txt' corrects the compiling errors but linking failed to find reference to libphonenumber library.
If adding the "-std=gnu++11 -ldl" flag to 'build/CMakeCache.txt' corrects all issues it implies non easy to find manual operation.

It would be great if we could add appropriate option directly in file 'CMakeList.txt' file.
Suggestion adding the 2 following lines in file 'CMakeList.txt':

SET(GCC_COVERAGE_COMPILE_FLAGS "-std=gnu++11 -ldl")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")

Release request?

We are using pn as a component in Sxmo and have packaged it for Alpine Linux. For the packaging effort in Linux distributions like Alpine, it would help if you could release pn with a version number using Github's release mechanism (and the appropriate git tag)?

Thanks!

Issue when linking

Hi,

I am having problems trying to link the binary with the last version of the libraries:

matthieu@matt-dev-box:~/go-work/src/github.com/Pragma-innovation/pn/build$ make
Scanning dependencies of target pn
[ 20%] Building CXX object CMakeFiles/pn.dir/src/pn.cc.o
[ 40%] Linking CXX executable pn
/usr/bin/ld: CMakeFiles/pn.dir/src/pn.cc.o: undefined reference to symbol '_ZN6icu_556LocaleC1EPKcS2_S2_S2_'
/usr/lib/x86_64-linux-gnu/libicuuc.so.55: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
CMakeFiles/pn.dir/build.make:97: recipe for target 'pn' failed
make[2]: *** [pn] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/pn.dir/all' failed
make[1]: *** [CMakeFiles/pn.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2
matthieu@matt-dev-box:~/go-work/src/github.com/Pragma-innovation/pn/build

I am using those library version (last version you get from apt-get on ubuntu current LTS version 16.04):

matthieu@matt-dev-box:~/go-work/src/github.com/Pragma-innovation/druid-drivers/pstn-cdr/pstnnumbertool/build$ sudo apt install cmake build-essential libphonenumber-dev libicu-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
libphonenumber-dev is already the newest version (7.0.8-0ubuntu3).
cmake is already the newest version (3.5.1-1ubuntu3).
libicu-dev is already the newest version (55.1-7ubuntu0.2).
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.

Could you please help me to investigate the issue ?

Thanks Matt.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.